python-cmr
Advanced tools
| [tool.poetry] | ||
| name = "python-cmr" | ||
| version = "0.7.0" | ||
| description = "Python wrapper to the NASA Common Metadata Repository (CMR) API." | ||
| authors = ["python_cmr <nasa/python_cmr@github.com>"] | ||
| license = "MIT" | ||
| readme = "README.md" | ||
| repository = "https://github.com/nasa/python_cmr" | ||
| classifiers = [ | ||
| "Topic :: Software Development :: Libraries :: Python Modules" | ||
| ] | ||
| packages = [{ include = "cmr" }] | ||
| [tool.poetry.dependencies] | ||
| python = "^3.8" | ||
| requests = "^2.26.0" | ||
| [tool.poetry.dev-dependencies] | ||
| flake8 = "^4.0.1" | ||
| pytest = "^6.2.5" | ||
| [build-system] | ||
| requires = ["poetry-core>=1.0.0"] | ||
| build-backend = "poetry.core.masonry.api" |
+32
-13
@@ -13,2 +13,3 @@ """ | ||
| from re import search | ||
| from requests import get, exceptions | ||
@@ -20,2 +21,3 @@ | ||
| class Query(object): | ||
@@ -214,4 +216,4 @@ """ | ||
| Collections, granules, tools, services are uniquely identified with this ID. | ||
| If providing a collection's concept ID here, it will filter by granules associated with that collection. | ||
| Collections, granules, tools, services are uniquely identified with this ID. | ||
| If providing a collection's concept ID here, it will filter by granules associated with that collection. | ||
| If providing a granule's concept ID here, it will uniquely identify those granules. | ||
@@ -227,7 +229,8 @@ If providing a tool's concept ID here, it will uniquely identify those tools. | ||
| IDs = [IDs] | ||
| # verify we weren't provided any granule concept IDs | ||
| for ID in IDs: | ||
| if ID.strip()[0] not in self.concept_id_chars: | ||
| raise ValueError("Only concept ids that begin with '{}' can be provided: {}".format(self.concept_id_chars, ID)) | ||
| raise ValueError( | ||
| "Only concept ids that begin with '{}' can be provided: {}".format(self.concept_id_chars, ID)) | ||
@@ -275,2 +278,16 @@ self.params["concept_id"] = IDs | ||
| def token(self, token): | ||
| """ | ||
| Add token into url request. | ||
| :param token: Token from EDL. | ||
| :returns: Query instance | ||
| """ | ||
| if not token: | ||
| return self | ||
| self.params['token'] = token | ||
| return self | ||
| class GranuleCollectionBaseQuery(Query): | ||
@@ -419,3 +436,3 @@ """ | ||
| return self | ||
| # make sure we were passed something iterable | ||
@@ -479,3 +496,3 @@ try: | ||
| return self | ||
| # make sure we were passed something iterable | ||
@@ -518,3 +535,3 @@ try: | ||
| del self.params["online_only"] | ||
| self.params['downloadable'] = downloadable | ||
@@ -716,3 +733,3 @@ | ||
| native_ids = [native_ids] | ||
| self.params["native_id"] = native_ids | ||
@@ -739,3 +756,3 @@ | ||
| raise ValueError("Only tool concept ID's can be provided (begin with 'T'): {}".format(ID)) | ||
| self.params["tool_concept_id"] = IDs | ||
@@ -757,3 +774,3 @@ | ||
| IDs = [IDs] | ||
| # verify we provided with service concept IDs | ||
@@ -763,3 +780,3 @@ for ID in IDs: | ||
| raise ValueError("Only service concept ID's can be provided (begin with 'S'): {}".format(ID)) | ||
| self.params["service_concept_id"] = IDs | ||
@@ -772,2 +789,3 @@ | ||
| class ToolServiceVariableBaseQuery(Query): | ||
@@ -823,3 +841,3 @@ """ | ||
| native_ids = [native_ids] | ||
| self.params["native_id"] = native_ids | ||
@@ -843,2 +861,3 @@ | ||
| class ToolQuery(ToolServiceVariableBaseQuery): | ||
@@ -885,2 +904,2 @@ """ | ||
| def _valid_state(self): | ||
| return True | ||
| return True |
+92
-24
| Metadata-Version: 2.1 | ||
| Name: python-cmr | ||
| Version: 0.6.0 | ||
| Version: 0.7.0 | ||
| Summary: Python wrapper to the NASA Common Metadata Repository (CMR) API. | ||
| Home-page: https://github.com/nasa/python_cmr | ||
| Author: https://github.com/orgs/nasa/teams/python-cmr | ||
| License: MIT | ||
| Platform: UNKNOWN | ||
| Author: python_cmr | ||
| Author-email: nasa/python_cmr@github.com | ||
| Requires-Python: >=3.8,<4.0 | ||
| Classifier: License :: OSI Approved :: MIT License | ||
| Classifier: Programming Language :: Python :: 3 | ||
| Classifier: Programming Language :: Python :: 3.10 | ||
| Classifier: Programming Language :: Python :: 3.8 | ||
| Classifier: Programming Language :: Python :: 3.9 | ||
| Classifier: Topic :: Software Development :: Libraries :: Python Modules | ||
| Requires-Dist: requests (>=2.26.0,<3.0.0) | ||
| Project-URL: Repository, https://github.com/nasa/python_cmr | ||
| Description-Content-Type: text/markdown | ||
| License-File: LICENSE | ||
| This repository is a copy of [jddeal/python_cmr](https://github.com/jddeal/python-cmr/tree/ef0f9e7d67ce99d342a568bd6a098c3462df16d2) which is no longer maintained. It has been copied here with the permission of the original author for the purpose of continuing to develop a python library that can be used for CMR access. | ||
| This repository is a copy | ||
| of [jddeal/python_cmr](https://github.com/jddeal/python-cmr/tree/ef0f9e7d67ce99d342a568bd6a098c3462df16d2) which is no | ||
| longer maintained. It has been copied here with the permission of the original author for the purpose of continuing to | ||
| develop a python library that can be used for CMR access. | ||
@@ -21,3 +32,6 @@ ---- | ||
| Python CMR is an easy to use wrapper to the NASA EOSDIS [Common Metadata Repository API](https://cmr.earthdata.nasa.gov/search/). This package aims to make querying the API intuitive and less error-prone by providing methods that will preemptively check for invalid input and handle the URL encoding the CMR API expects. | ||
| Python CMR is an easy to use wrapper to the NASA | ||
| EOSDIS [Common Metadata Repository API](https://cmr.earthdata.nasa.gov/search/). This package aims to make querying the | ||
| API intuitive and less error-prone by providing methods that will preemptively check for invalid input and handle the | ||
| URL encoding the CMR API expects. | ||
@@ -62,3 +76,5 @@ Getting access to NASA's earth science metadata is as simple as this: | ||
| This library is broken into two classes, CollectionQuery and GranuleQuery. Each of these classes provide a large set of methods used to build a query for CMR. Not all parameters provided by the CMR API are covered by this version of python-cmr. | ||
| This library is broken into two classes, CollectionQuery and GranuleQuery. Each of these classes provide a large set of | ||
| methods used to build a query for CMR. Not all parameters provided by the CMR API are covered by this version of | ||
| python-cmr. | ||
@@ -187,3 +203,4 @@ The following methods are available to both collecton and granule queries: | ||
| As an alternative to chaining methods together to set the parameters of your query, a method exists to allow you to pass your parameters as keyword arguments: | ||
| As an alternative to chaining methods together to set the parameters of your query, a method exists to allow you to pass | ||
| your parameters as keyword arguments: | ||
@@ -197,3 +214,4 @@ # search for AST_L1T version 003 granules at latitude 42, longitude -100 | ||
| Note: the kwarg key should match the name of a method from the above examples, and the value should be a tuple if it's a parameter that requires multiple values. | ||
| Note: the kwarg key should match the name of a method from the above examples, and the value should be a tuple if it's a | ||
| parameter that requires multiple values. | ||
@@ -214,3 +232,4 @@ To inspect and retreive results from the API, the following methods are available: | ||
| By default the responses will return as json and be accessible as a list of python dictionaries. Other formats can be specified before making the request: | ||
| By default the responses will return as json and be accessible as a list of python dictionaries. Other formats can be | ||
| specified before making the request: | ||
@@ -221,20 +240,69 @@ >>> granules = api.format("echo10").get(100) | ||
| - json (default) | ||
| - xml | ||
| - echo10 | ||
| - iso | ||
| - iso19115 | ||
| - csv | ||
| - atom | ||
| - kml | ||
| - native | ||
| - json (default) | ||
| - xml | ||
| - echo10 | ||
| - iso | ||
| - iso19115 | ||
| - csv | ||
| - atom | ||
| - kml | ||
| - native | ||
| Collection queries also support the following formats: | ||
| - dif | ||
| - dif10 | ||
| - opendata | ||
| - umm\_json | ||
| - umm\_json\_vX\_Y (ex: umm\_json\_v1\_9) | ||
| - dif | ||
| - dif10 | ||
| - opendata | ||
| - umm\_json | ||
| - umm\_json\_vX\_Y (ex: umm\_json\_v1\_9) | ||
| # Developing | ||
| python-cmr uses the [poetry](https://python-poetry.org/) build system. Download and install poetry before starting | ||
| development | ||
| ## Install Dependencies | ||
| With dev dependencies: | ||
| ```shell | ||
| poetry install | ||
| ``` | ||
| Without dev dependencies: | ||
| ```shell | ||
| poetry install --no-dev | ||
| ``` | ||
| ## Update Dependencies | ||
| ```shell | ||
| poetry update | ||
| ``` | ||
| ## Add new Dependency | ||
| ```shell | ||
| poetry add requests | ||
| ``` | ||
| Development-only dependency: | ||
| ```shell | ||
| poetry add --dev pytest | ||
| ``` | ||
| ## Build project | ||
| ```shell | ||
| poetry build | ||
| ``` | ||
| ## Lint project | ||
| ```shell | ||
| poetry run flake8 | ||
| ``` | ||
| ## Run Tests | ||
| ```shell | ||
| poetry run pytest | ||
| ``` |
+82
-20
@@ -1,2 +0,5 @@ | ||
| This repository is a copy of [jddeal/python_cmr](https://github.com/jddeal/python-cmr/tree/ef0f9e7d67ce99d342a568bd6a098c3462df16d2) which is no longer maintained. It has been copied here with the permission of the original author for the purpose of continuing to develop a python library that can be used for CMR access. | ||
| This repository is a copy | ||
| of [jddeal/python_cmr](https://github.com/jddeal/python-cmr/tree/ef0f9e7d67ce99d342a568bd6a098c3462df16d2) which is no | ||
| longer maintained. It has been copied here with the permission of the original author for the purpose of continuing to | ||
| develop a python library that can be used for CMR access. | ||
@@ -10,3 +13,6 @@ ---- | ||
| Python CMR is an easy to use wrapper to the NASA EOSDIS [Common Metadata Repository API](https://cmr.earthdata.nasa.gov/search/). This package aims to make querying the API intuitive and less error-prone by providing methods that will preemptively check for invalid input and handle the URL encoding the CMR API expects. | ||
| Python CMR is an easy to use wrapper to the NASA | ||
| EOSDIS [Common Metadata Repository API](https://cmr.earthdata.nasa.gov/search/). This package aims to make querying the | ||
| API intuitive and less error-prone by providing methods that will preemptively check for invalid input and handle the | ||
| URL encoding the CMR API expects. | ||
@@ -51,3 +57,5 @@ Getting access to NASA's earth science metadata is as simple as this: | ||
| This library is broken into two classes, CollectionQuery and GranuleQuery. Each of these classes provide a large set of methods used to build a query for CMR. Not all parameters provided by the CMR API are covered by this version of python-cmr. | ||
| This library is broken into two classes, CollectionQuery and GranuleQuery. Each of these classes provide a large set of | ||
| methods used to build a query for CMR. Not all parameters provided by the CMR API are covered by this version of | ||
| python-cmr. | ||
@@ -176,3 +184,4 @@ The following methods are available to both collecton and granule queries: | ||
| As an alternative to chaining methods together to set the parameters of your query, a method exists to allow you to pass your parameters as keyword arguments: | ||
| As an alternative to chaining methods together to set the parameters of your query, a method exists to allow you to pass | ||
| your parameters as keyword arguments: | ||
@@ -186,3 +195,4 @@ # search for AST_L1T version 003 granules at latitude 42, longitude -100 | ||
| Note: the kwarg key should match the name of a method from the above examples, and the value should be a tuple if it's a parameter that requires multiple values. | ||
| Note: the kwarg key should match the name of a method from the above examples, and the value should be a tuple if it's a | ||
| parameter that requires multiple values. | ||
@@ -203,3 +213,4 @@ To inspect and retreive results from the API, the following methods are available: | ||
| By default the responses will return as json and be accessible as a list of python dictionaries. Other formats can be specified before making the request: | ||
| By default the responses will return as json and be accessible as a list of python dictionaries. Other formats can be | ||
| specified before making the request: | ||
@@ -210,18 +221,69 @@ >>> granules = api.format("echo10").get(100) | ||
| - json (default) | ||
| - xml | ||
| - echo10 | ||
| - iso | ||
| - iso19115 | ||
| - csv | ||
| - atom | ||
| - kml | ||
| - native | ||
| - json (default) | ||
| - xml | ||
| - echo10 | ||
| - iso | ||
| - iso19115 | ||
| - csv | ||
| - atom | ||
| - kml | ||
| - native | ||
| Collection queries also support the following formats: | ||
| - dif | ||
| - dif10 | ||
| - opendata | ||
| - umm\_json | ||
| - umm\_json\_vX\_Y (ex: umm\_json\_v1\_9) | ||
| - dif | ||
| - dif10 | ||
| - opendata | ||
| - umm\_json | ||
| - umm\_json\_vX\_Y (ex: umm\_json\_v1\_9) | ||
| # Developing | ||
| python-cmr uses the [poetry](https://python-poetry.org/) build system. Download and install poetry before starting | ||
| development | ||
| ## Install Dependencies | ||
| With dev dependencies: | ||
| ```shell | ||
| poetry install | ||
| ``` | ||
| Without dev dependencies: | ||
| ```shell | ||
| poetry install --no-dev | ||
| ``` | ||
| ## Update Dependencies | ||
| ```shell | ||
| poetry update | ||
| ``` | ||
| ## Add new Dependency | ||
| ```shell | ||
| poetry add requests | ||
| ``` | ||
| Development-only dependency: | ||
| ```shell | ||
| poetry add --dev pytest | ||
| ``` | ||
| ## Build project | ||
| ```shell | ||
| poetry build | ||
| ``` | ||
| ## Lint project | ||
| ```shell | ||
| poetry run flake8 | ||
| ``` | ||
| ## Run Tests | ||
| ```shell | ||
| poetry run pytest | ||
| ``` |
+28
-14
@@ -0,16 +1,30 @@ | ||
| # -*- coding: utf-8 -*- | ||
| from setuptools import setup | ||
| setup( | ||
| name="python-cmr", | ||
| version="0.6.0", | ||
| license="MIT", | ||
| url="https://github.com/nasa/python_cmr", | ||
| description="Python wrapper to the NASA Common Metadata Repository (CMR) API.", | ||
| long_description=open("README.md").read(), | ||
| long_description_content_type='text/markdown', | ||
| author="https://github.com/orgs/nasa/teams/python-cmr", | ||
| packages=["cmr"], | ||
| install_requires=[ | ||
| "requests", | ||
| ] | ||
| ) | ||
| packages = \ | ||
| ['cmr'] | ||
| package_data = \ | ||
| {'': ['*']} | ||
| install_requires = \ | ||
| ['requests>=2.26.0,<3.0.0'] | ||
| setup_kwargs = { | ||
| 'name': 'python-cmr', | ||
| 'version': '0.7.0', | ||
| 'description': 'Python wrapper to the NASA Common Metadata Repository (CMR) API.', | ||
| 'long_description': 'This repository is a copy\nof [jddeal/python_cmr](https://github.com/jddeal/python-cmr/tree/ef0f9e7d67ce99d342a568bd6a098c3462df16d2) which is no\nlonger maintained. It has been copied here with the permission of the original author for the purpose of continuing to\ndevelop a python library that can be used for CMR access.\n\n----\n\nPython CMR\n==========\n\n[](https://github.com/nasa/python_cmr/actions/workflows/codeql-analysis.yml)\n\nPython CMR is an easy to use wrapper to the NASA\nEOSDIS [Common Metadata Repository API](https://cmr.earthdata.nasa.gov/search/). This package aims to make querying the\nAPI intuitive and less error-prone by providing methods that will preemptively check for invalid input and handle the\nURL encoding the CMR API expects.\n\nGetting access to NASA\'s earth science metadata is as simple as this:\n\n >>> from cmr import CollectionQuery, GranuleQuery, ToolQuery, ServiceQuery, VariableQuery\n\n >>> api = CollectionQuery()\n >>> collections = api.archive_center("LP DAAC").keyword("AST_L1*").get(5)\n\n >>> for collection in collections:\n >>> print(collection["short_name"])\n AST_L1A\n AST_L1AE\n AST_L1T\n\n >>> api = GranuleQuery()\n >>> granules = api.short_name("AST_L1T").point(-112.73, 42.5).get(3)\n\n >>> for granule in granules:\n >>> print(granule["title"])\n SC:AST_L1T.003:2149105822\n SC:AST_L1T.003:2149105820\n SC:AST_L1T.003:2149155037\n\nInstallation\n============\n\nTo install from pypi:\n\n $ pip install python-cmr\n\nTo install from github, perhaps to try out the dev branch:\n\n $ git clone https://github.com/nasa/python_cmr\n $ cd python-cmr\n $ pip install .\n\nExamples\n========\n\nThis library is broken into two classes, CollectionQuery and GranuleQuery. Each of these classes provide a large set of\nmethods used to build a query for CMR. Not all parameters provided by the CMR API are covered by this version of\npython-cmr.\n\nThe following methods are available to both collecton and granule queries:\n\n # search for granules matching a specific product/short_name\n >>> api.short_name("AST_L1T")\n\n # search for granules matching a specific version\n >>> api.version("006")\n\n # search for granules at a specific longitude and latitude\n >>> api.point(-112.73, 42.5)\n\n # search for granules in an area bound by a box (lower left lon/lat, upper right lon/lat)\n >>> api.bounding_box(-112.70, 42.5, -110, 44.5)\n\n # search for granules in a polygon (these need to be in counter clockwise order and the\n # last coordinate must match the first in order to close the polygon)\n >>> api.polygon([(-100, 40), (-110, 40), (-105, 38), (-100, 40)])\n\n # search for granules in a line\n >>> api.line([(-100, 40), (-90, 40), (-95, 38)])\n\n # search for granules in an open or closed date range\n >>> api.temporal("2016-10-10T01:02:00Z", "2016-10-12T00:00:30Z")\n >>> api.temporal("2016-10-10T01:02:00Z", None)\n >>> api.temporal(datetime(2016, 10, 10, 1, 2, 0), datetime.now())\n\n # only include granules available for download\n >>> api.downloadable()\n\n # only include granules that are unavailable for download\n >>> api.online_only()\n\n # search for collections/granules associated with or identified by concept IDs\n # note: often the ECHO collection ID can be used here as well\n # note: when using CollectionQuery, only collection concept IDs can be passed\n # note: when uses GranuleQuery, passing a collection\'s concept ID will filter by granules associated\n # with that particular collection.\n >>> api.concept_id("C1299783579-LPDAAC_ECS")\n >>> api.concept_id(["G1327299284-LPDAAC_ECS", "G1326330014-LPDAAC_ECS"])\n\n # search by provider\n >>> api.provider(\'POCLOUD\')\n\nGranule searches support these methods (in addition to the shared methods above):\n\n # search for a granule by its unique ID\n >>> api.granule_ur("SC:AST_L1T.003:2150315169")\n # search for granules from a specific orbit\n >>> api.orbit_number(5000)\n\n # filter by the day/night flag\n >>> api.day_night_flag("day")\n\n # filter by cloud cover percentage range\n >>> api.cloud_cover(25, 75)\n\n # filter by specific instrument or platform\n >>> api.instrument("MODIS")\n >>> api.platform("Terra")\n\nCollection searches support these methods (in addition to the shared methods above):\n\n # search for collections from a specific archive center\n >>> api.archive_center("LP DAAC")\n\n # case insensitive, wildcard enabled text search through most collection fields\n >>> api.keyword("M*D09")\n\n # search by native_id\n >>> api.native_id(\'native_id\')\n\n # filter by tool concept id\n >>> api.tool_concept_id(\'TL2092786348-POCLOUD\')\n\n # filter by service concept id\n >>> api.service_concept_id(\'S1962070864-POCLOUD\')\n\nService searches support the following methods\n\n # Search via provider\n >>> api = ServiceQuery()\n >>> api.provider(\'POCLOUD\')\n \n # Search via native_id\n >>> api.native_id(\'POCLOUD_podaac_l2_cloud_subsetter\')\n\n # Search via name\n >>> api.name(\'PODAAC L2 Cloud Subsetter\')\n\n # Search via concept_id\n >>> api.concept_id(\'S1962070864-POCLOUD\')\n\nTool searches support the following methods\n\n # Search via provider\n >>> api = ToolQuery()\n >>> api.provider(\'POCLOUD\')\n\n # Search via native_id\n >>> api.native_id(\'POCLOUD_hitide\')\n\n # Search via name\n >>> api.name(\'hitide\')\n\n # Search via concept_id\n >>> api.concept_id(\'TL2092786348-POCLOUD\')\n\nVariable searches support the following methods\n\n # Search via provider\n >>> api = VariableQuery()\n >>> api.provider(\'POCLOUD\')\n\n # Search via native_id\n >>> api.native_id(\'JASON_CS_S6A_L2_AMR_RAD_STATIC_CALIBRATION-AMR_Side_1-acc_lat\')\n\n # Search via name\n >>> api.name(\'/AMR_Side_1/acc_lat\')\n\n # Search via concept_id\n >>> api.concept_id(\'V2112019824-POCLOUD\')\n\nAs an alternative to chaining methods together to set the parameters of your query, a method exists to allow you to pass\nyour parameters as keyword arguments:\n\n # search for AST_L1T version 003 granules at latitude 42, longitude -100\n >>> api.parameters(\n short_name="AST_L1T",\n version="003",\n point=(-100, 42)\n )\n\nNote: the kwarg key should match the name of a method from the above examples, and the value should be a tuple if it\'s a\nparameter that requires multiple values.\n\nTo inspect and retreive results from the API, the following methods are available:\n\n # inspect the number of results the query will return without downloading the results\n >>> print(api.hits())\n\n # retrieve 100 granules\n >>> granules = api.get(100)\n\n # retrieve 25,000 granules\n >>> granules = api.get(25000)\n\n # retrieve all the granules possible for the query\n >>> granules = api.get_all() # this is a shortcut for api.get(api.hits())\n\nBy default the responses will return as json and be accessible as a list of python dictionaries. Other formats can be\nspecified before making the request:\n\n >>> granules = api.format("echo10").get(100)\n\nThe following formats are supported for both granule and collection queries:\n\n- json (default)\n- xml\n- echo10\n- iso\n- iso19115\n- csv\n- atom\n- kml\n- native\n\nCollection queries also support the following formats:\n\n- dif\n- dif10\n- opendata\n- umm\\_json\n- umm\\_json\\_vX\\_Y (ex: umm\\_json\\_v1\\_9)\n\n# Developing\n\npython-cmr uses the [poetry](https://python-poetry.org/) build system. Download and install poetry before starting\ndevelopment\n\n## Install Dependencies\n\nWith dev dependencies:\n```shell\npoetry install\n```\n\nWithout dev dependencies:\n```shell\npoetry install --no-dev\n```\n\n## Update Dependencies\n\n```shell\npoetry update\n```\n\n## Add new Dependency\n\n```shell\npoetry add requests\n```\nDevelopment-only dependency:\n```shell\npoetry add --dev pytest\n```\n\n## Build project\n\n```shell\npoetry build\n```\n\n## Lint project\n\n```shell\npoetry run flake8\n```\n\n## Run Tests\n\n```shell\npoetry run pytest\n```', | ||
| 'author': 'python_cmr', | ||
| 'author_email': 'nasa/python_cmr@github.com', | ||
| 'maintainer': None, | ||
| 'maintainer_email': None, | ||
| 'url': 'https://github.com/nasa/python_cmr', | ||
| 'packages': packages, | ||
| 'package_data': package_data, | ||
| 'install_requires': install_requires, | ||
| 'python_requires': '>=3.8,<4.0', | ||
| } | ||
| setup(**setup_kwargs) |
| include LICENSE | ||
| include README.rst |
| Metadata-Version: 2.1 | ||
| Name: python-cmr | ||
| Version: 0.6.0 | ||
| Summary: Python wrapper to the NASA Common Metadata Repository (CMR) API. | ||
| Home-page: https://github.com/nasa/python_cmr | ||
| Author: https://github.com/orgs/nasa/teams/python-cmr | ||
| License: MIT | ||
| Platform: UNKNOWN | ||
| Description-Content-Type: text/markdown | ||
| License-File: LICENSE | ||
| This repository is a copy of [jddeal/python_cmr](https://github.com/jddeal/python-cmr/tree/ef0f9e7d67ce99d342a568bd6a098c3462df16d2) which is no longer maintained. It has been copied here with the permission of the original author for the purpose of continuing to develop a python library that can be used for CMR access. | ||
| ---- | ||
| Python CMR | ||
| ========== | ||
| [](https://github.com/nasa/python_cmr/actions/workflows/codeql-analysis.yml) | ||
| Python CMR is an easy to use wrapper to the NASA EOSDIS [Common Metadata Repository API](https://cmr.earthdata.nasa.gov/search/). This package aims to make querying the API intuitive and less error-prone by providing methods that will preemptively check for invalid input and handle the URL encoding the CMR API expects. | ||
| Getting access to NASA's earth science metadata is as simple as this: | ||
| >>> from cmr import CollectionQuery, GranuleQuery, ToolQuery, ServiceQuery, VariableQuery | ||
| >>> api = CollectionQuery() | ||
| >>> collections = api.archive_center("LP DAAC").keyword("AST_L1*").get(5) | ||
| >>> for collection in collections: | ||
| >>> print(collection["short_name"]) | ||
| AST_L1A | ||
| AST_L1AE | ||
| AST_L1T | ||
| >>> api = GranuleQuery() | ||
| >>> granules = api.short_name("AST_L1T").point(-112.73, 42.5).get(3) | ||
| >>> for granule in granules: | ||
| >>> print(granule["title"]) | ||
| SC:AST_L1T.003:2149105822 | ||
| SC:AST_L1T.003:2149105820 | ||
| SC:AST_L1T.003:2149155037 | ||
| Installation | ||
| ============ | ||
| To install from pypi: | ||
| $ pip install python-cmr | ||
| To install from github, perhaps to try out the dev branch: | ||
| $ git clone https://github.com/nasa/python_cmr | ||
| $ cd python-cmr | ||
| $ pip install . | ||
| Examples | ||
| ======== | ||
| This library is broken into two classes, CollectionQuery and GranuleQuery. Each of these classes provide a large set of methods used to build a query for CMR. Not all parameters provided by the CMR API are covered by this version of python-cmr. | ||
| The following methods are available to both collecton and granule queries: | ||
| # search for granules matching a specific product/short_name | ||
| >>> api.short_name("AST_L1T") | ||
| # search for granules matching a specific version | ||
| >>> api.version("006") | ||
| # search for granules at a specific longitude and latitude | ||
| >>> api.point(-112.73, 42.5) | ||
| # search for granules in an area bound by a box (lower left lon/lat, upper right lon/lat) | ||
| >>> api.bounding_box(-112.70, 42.5, -110, 44.5) | ||
| # search for granules in a polygon (these need to be in counter clockwise order and the | ||
| # last coordinate must match the first in order to close the polygon) | ||
| >>> api.polygon([(-100, 40), (-110, 40), (-105, 38), (-100, 40)]) | ||
| # search for granules in a line | ||
| >>> api.line([(-100, 40), (-90, 40), (-95, 38)]) | ||
| # search for granules in an open or closed date range | ||
| >>> api.temporal("2016-10-10T01:02:00Z", "2016-10-12T00:00:30Z") | ||
| >>> api.temporal("2016-10-10T01:02:00Z", None) | ||
| >>> api.temporal(datetime(2016, 10, 10, 1, 2, 0), datetime.now()) | ||
| # only include granules available for download | ||
| >>> api.downloadable() | ||
| # only include granules that are unavailable for download | ||
| >>> api.online_only() | ||
| # search for collections/granules associated with or identified by concept IDs | ||
| # note: often the ECHO collection ID can be used here as well | ||
| # note: when using CollectionQuery, only collection concept IDs can be passed | ||
| # note: when uses GranuleQuery, passing a collection's concept ID will filter by granules associated | ||
| # with that particular collection. | ||
| >>> api.concept_id("C1299783579-LPDAAC_ECS") | ||
| >>> api.concept_id(["G1327299284-LPDAAC_ECS", "G1326330014-LPDAAC_ECS"]) | ||
| # search by provider | ||
| >>> api.provider('POCLOUD') | ||
| Granule searches support these methods (in addition to the shared methods above): | ||
| # search for a granule by its unique ID | ||
| >>> api.granule_ur("SC:AST_L1T.003:2150315169") | ||
| # search for granules from a specific orbit | ||
| >>> api.orbit_number(5000) | ||
| # filter by the day/night flag | ||
| >>> api.day_night_flag("day") | ||
| # filter by cloud cover percentage range | ||
| >>> api.cloud_cover(25, 75) | ||
| # filter by specific instrument or platform | ||
| >>> api.instrument("MODIS") | ||
| >>> api.platform("Terra") | ||
| Collection searches support these methods (in addition to the shared methods above): | ||
| # search for collections from a specific archive center | ||
| >>> api.archive_center("LP DAAC") | ||
| # case insensitive, wildcard enabled text search through most collection fields | ||
| >>> api.keyword("M*D09") | ||
| # search by native_id | ||
| >>> api.native_id('native_id') | ||
| # filter by tool concept id | ||
| >>> api.tool_concept_id('TL2092786348-POCLOUD') | ||
| # filter by service concept id | ||
| >>> api.service_concept_id('S1962070864-POCLOUD') | ||
| Service searches support the following methods | ||
| # Search via provider | ||
| >>> api = ServiceQuery() | ||
| >>> api.provider('POCLOUD') | ||
| # Search via native_id | ||
| >>> api.native_id('POCLOUD_podaac_l2_cloud_subsetter') | ||
| # Search via name | ||
| >>> api.name('PODAAC L2 Cloud Subsetter') | ||
| # Search via concept_id | ||
| >>> api.concept_id('S1962070864-POCLOUD') | ||
| Tool searches support the following methods | ||
| # Search via provider | ||
| >>> api = ToolQuery() | ||
| >>> api.provider('POCLOUD') | ||
| # Search via native_id | ||
| >>> api.native_id('POCLOUD_hitide') | ||
| # Search via name | ||
| >>> api.name('hitide') | ||
| # Search via concept_id | ||
| >>> api.concept_id('TL2092786348-POCLOUD') | ||
| Variable searches support the following methods | ||
| # Search via provider | ||
| >>> api = VariableQuery() | ||
| >>> api.provider('POCLOUD') | ||
| # Search via native_id | ||
| >>> api.native_id('JASON_CS_S6A_L2_AMR_RAD_STATIC_CALIBRATION-AMR_Side_1-acc_lat') | ||
| # Search via name | ||
| >>> api.name('/AMR_Side_1/acc_lat') | ||
| # Search via concept_id | ||
| >>> api.concept_id('V2112019824-POCLOUD') | ||
| As an alternative to chaining methods together to set the parameters of your query, a method exists to allow you to pass your parameters as keyword arguments: | ||
| # search for AST_L1T version 003 granules at latitude 42, longitude -100 | ||
| >>> api.parameters( | ||
| short_name="AST_L1T", | ||
| version="003", | ||
| point=(-100, 42) | ||
| ) | ||
| Note: the kwarg key should match the name of a method from the above examples, and the value should be a tuple if it's a parameter that requires multiple values. | ||
| To inspect and retreive results from the API, the following methods are available: | ||
| # inspect the number of results the query will return without downloading the results | ||
| >>> print(api.hits()) | ||
| # retrieve 100 granules | ||
| >>> granules = api.get(100) | ||
| # retrieve 25,000 granules | ||
| >>> granules = api.get(25000) | ||
| # retrieve all the granules possible for the query | ||
| >>> granules = api.get_all() # this is a shortcut for api.get(api.hits()) | ||
| By default the responses will return as json and be accessible as a list of python dictionaries. Other formats can be specified before making the request: | ||
| >>> granules = api.format("echo10").get(100) | ||
| The following formats are supported for both granule and collection queries: | ||
| - json (default) | ||
| - xml | ||
| - echo10 | ||
| - iso | ||
| - iso19115 | ||
| - csv | ||
| - atom | ||
| - kml | ||
| - native | ||
| Collection queries also support the following formats: | ||
| - dif | ||
| - dif10 | ||
| - opendata | ||
| - umm\_json | ||
| - umm\_json\_vX\_Y (ex: umm\_json\_v1\_9) | ||
| requests |
| LICENSE | ||
| MANIFEST.in | ||
| README.md | ||
| setup.py | ||
| cmr/__init__.py | ||
| cmr/queries.py | ||
| python_cmr.egg-info/PKG-INFO | ||
| python_cmr.egg-info/SOURCES.txt | ||
| python_cmr.egg-info/dependency_links.txt | ||
| python_cmr.egg-info/requires.txt | ||
| python_cmr.egg-info/top_level.txt |
| [egg_info] | ||
| tag_build = | ||
| tag_date = 0 | ||
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
53963
5.6%705
7.31%7
-46.15%