Python CMR is an easy to use wrapper to the NASA EOSDIS Common Metadata Repository API.

Overview

This repository is a copy of jddeal/python_cmr 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

CodeQL

Python CMR is an easy to use wrapper to the NASA EOSDIS Common Metadata Repository API. 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:

>> 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 ">
>>> from cmr import CollectionQuery, GranuleQuery

>>> 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/jddeal/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:

>> 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') ">
# 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):

>> 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") ">
# 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):

>> 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') ">
# 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')

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')

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)
Comments
  • Variablesquery

    Variablesquery

    • Added in VariableQuery class to query umm-v
    • Added in tests for VariableQuery
    • Changed url in readme for github url
    • Concept_id function return self so we can chain functions
    opened by sliu008 1
  • Release/0.7.0

    Release/0.7.0

    [0.7.0]

    Added

    • New workflow that runs lint and test
    • New function Query.token to add an auth token to the request sent to CMR

    Changed

    opened by frankinspace 0
  • Release/0.6.0

    Release/0.6.0

    [0.6.0]

    Added

    • New support for querying variables (UMM-V)

    Changed

    • Can now import ToolQuery ServiceQuery VariableQuery straight from cmr module. (e.g. from cmr import ToolQuery)
    opened by frankinspace 0
  • Release/0.5.0

    Release/0.5.0

    [0.5.0]

    Added

    • New support for querying tools (UMM-T) and services (UMM-S)
    • CodeQL Analysis on pushes and pull requests

    Changed

    • Moved to github.com/nasa/python_cmr
    opened by frankinspace 0
  • New searching criterion: circle

    New searching criterion: circle

    Similar to the point criterion but includes a buffer around the point. One application is searching for granules with data within a certain distance of a waypoint such as a mooring or a meteorological station.

    opened by castelao 0
  • Bump certifi from 2021.10.8 to 2022.12.7

    Bump certifi from 2021.10.8 to 2022.12.7

    Bumps certifi from 2021.10.8 to 2022.12.7.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
Releases(v0.7.0)
  • v0.7.0(Nov 23, 2021)

    [0.7.0]

    Added

    • New workflow that runs lint and test
    • New function Query.token to add an authentication token to the request sent to CMR

    Changed

    What's Changed

    • Create python-app.yml by @frankinspace in https://github.com/nasa/python_cmr/pull/7
    • Feature/token by @sliu008 in https://github.com/nasa/python_cmr/pull/8
    • Release/0.7.0 by @frankinspace in https://github.com/nasa/python_cmr/pull/9

    Full Changelog: https://github.com/nasa/python_cmr/compare/v0.6.0...v0.7.0

    Source code(tar.gz)
    Source code(zip)
  • v0.6.0(Oct 28, 2021)

    [0.6.0]

    Added

    • New support for querying variables (UMM-V)

    Changed

    • Can now import ToolQuery ServiceQuery VariableQuery straight from cmr module. (e.g. from cmr import ToolQuery)
    Source code(tar.gz)
    Source code(zip)
  • v0.5.0(Oct 15, 2021)

    [0.5.0]

    Added

    • New support for querying tools (UMM-T) and services (UMM-S)
    • CodeQL Analysis on pushes and pull requests

    Changed

    • Moved to github.com/nasa/python_cmr
    Source code(tar.gz)
    Source code(zip)
Owner
NASA
Read about NASA's Open Data initiative here: https://www.nasa.gov/open/ & Members Find Instructions here: http://nasa.github.io/
NASA
🤖 A discord bot for Dota2 community

BOTA BOT-A is a free Discord Dota 2 bot which provides comprehensive Information of every Dota 2 characters and exciting features for the community. P

Bendang 23 Jun 29, 2022
Using AWS Batch jobs to bulk copy/sync files in S3

Using AWS Batch jobs to bulk copy/sync files in S3

AWS Samples 14 Sep 19, 2022
Surfline Forecast Bot For Python

Surfline Forecast Bot A telegram bot created using Telethon that allows users to

1 May 08, 2022
Projeto sobre BioInformática - MoA (mecanismos de ação)

Projeto: MoA no Paredawn Projeto sobre Bioinformatica - Mecanismos de Ação (MoA) MODELO PREDITIVO PARA PREVER O ATIVAMENTO DO MOA E MODELO PARA PREVER

Junior Torres 36 Feb 15, 2022
An EmbedBuilder for Discord bots in Python.

An EmbedBuilder for Discord bots in Python. You need discord.py to use this module.

6 Jan 13, 2022
Python wrapper for Revolt API

defectio is a direct implementation of the entire Revolt API and provides a way to authenticate and start communicating with Revolt servers. Similar interface to discord.py

Leon Bowie 26 Sep 18, 2022
TFT Bot that automatically surrenders and allows finishing TFT Passes easily.

Image Based TFT Bot TFT Bot that automatically surrenders and allows finishing TFT Passes easily. Please read full file! You can check new releases he

1 Feb 06, 2022
Estimate the total emissions for popular CryptoArt platforms.

cryptoart-footprint Estimate the total CO2 footprint for popular CryptoArt platforms. The goal is to accurately quantify the ecological damage of Ethe

Kyle McDonald 182 Oct 12, 2022
TORNADO CASH Proxy Pancakeswap Sniper BOT 2022-V1 (MAC WINDOWS ANDROID LINUX)

TORNADO CASH Pancakeswap Sniper BOT 2022-V1 (MAC WINDOWS ANDROID LINUX) ⭐️ A ful

Crypto Trader 1 Jan 06, 2022
NoChannelBot - Bot bans users, that send messages like channels

No Channel Bot Say "STOP" to users who send messages as channels! Bot prevents u

Andrew 10 Oct 05, 2022
An example of matrix addition, demonstrating the basic method of Python calling C library functions

Example for Python call C functions An example of matrix addition, demonstrating the basic method of Python calling C library functions. How to run Bu

Quantum LIu 2 Dec 21, 2021
Discord Rich Presence for Team Fortress 2

TF2 Rich Presence Discord Rich Presence for Team Fortress 2 Detects current game state, queue info, playtime, and more Configurable, reliable, and per

Kataiser 33 Dec 31, 2022
A simple, multipurpose Discord bot.

EpicBot 🏅 A simple, multipurpose Discord bot. • Info EpicBot is a multipurpose Discord bot that was designed to make your Discord life easier and coo

Nirlep_5252_ 130 Dec 29, 2022
Enables you to execute scripts and perform API requests in MikroTik router

HomeAssistant component: MikroTik API The mikrotik_api platform enables you to execute scripts and perform API requests in MikroTik router To enable M

Pavel S 6 Aug 12, 2022
A wrapper to stream information from Twitter's Full-Archive Search Endpoint

A wrapper to stream information from Twitter's Full-Archive Search Endpoint. To exploit this library, one must have approved academic research access.

Daniela Pinto Veizaga 9 Nov 28, 2022
Previewer for VapourSynth scripts.

Standalone previewer for VapourSynth scripts Fork of Endilll's vapoursynth-preview (not maintained anymore) This program is meant to be paired with a

Irrational Encoding Wizardry 26 Dec 16, 2022
Powerful Telegram Maintained UserBot in Telethon

Fire-X UserBot The Awaited Bot Fire-X userbot The Most Powerful Telegram Userbot. This Userbot is Safe to use in Your Telegram Account. It is not like

22 Oct 21, 2022
Change the discord status throught websocket every 5 seconds with an insult

Discord status insult changer Change the discord status throught websocket every 5 seconds with an insult! - pip install httpx - put your tokens in "t

Ѵιcнч 10 Oct 27, 2022
A program to convert YouTube channel registration information into Json files for ThirdTube.

ThirdTubeImporter A program to convert YouTube channel registration information into Json files for ThirdTube. Usage Japanese https://takeout.google.c

Hidegon 2 Dec 18, 2021
OpenEmu Discord Rich Presence provided with Python!

A simple application that provides your current OpenEmu game as an RPC state in Discord via PyPresence. How to use Unzip and open the latest x86_64 ve

Deltaion Lee 6 May 30, 2022