Jupyternotebook

1. Search for 'SST' using collection search.

[4]:
import urllib.request
from xml.etree import ElementTree

url = 'https://gpwos1.jaxa.jp/examind/api/WS/csw/preview/opensearch'

params = {'service':'CSW',
          'version':'3.0.0',
          'outputFormat':'application/atom+xml',
          'q':'sst'}

query = urllib.parse.urlencode(params)

request = urllib.request.Request(url=url+'?'+query)

collections = {}
with urllib.request.urlopen(request) as res:
    xml = res.read()
    root = ElementTree.fromstring( xml )

    namespaces = {"a":"http://www.w3.org/2005/Atom"}

    for node in root.findall("a:entry", namespaces ):
        id = node.find('a:id', namespaces ).text
        granule_osdd = node.find("a:link[@title='Granule search']", namespaces).attrib['href']
        collections[id] = granule_osdd

print( collections )

{'ADEOS_OCTS_L2_RTC_SST': 'https://gpwos1.jaxa.jp/examind/api/WS/csw/ADEOS_OCTS_L2_RTC_SST/descriptionDocument.xml', 'ADEOS_OCTS_L3B_GAC_SST_1month': 'https://gpwos1.jaxa.jp/examind/api/WS/csw/ADEOS_OCTS_L3B_GAC_SST_1month/descriptionDocument.xml', 'ADEOS-II_GLI_L3B_SNWTS_16days_1-12deg': 'https://gpwos1.jaxa.jp/examind/api/WS/csw/ADEOS-II_GLI_L3B_SNWTS_16days_1-12deg/descriptionDocument.xml', 'ADEOS_OCTS_L3B_GAC_SST_1day': 'https://gpwos1.jaxa.jp/examind/api/WS/csw/ADEOS_OCTS_L3B_GAC_SST_1day/descriptionDocument.xml', 'GCOM-W_AMSR2_L2_SST': 'https://gpwos1.jaxa.jp/examind/api/WS/csw/GCOM-W_AMSR2_L2_SST/descriptionDocument.xml', 'ADEOS-II_GLI_L3STA_Map_ST_ALL_1day_9km': 'https://gpwos1.jaxa.jp/examind/api/WS/csw/ADEOS-II_GLI_L3STA_Map_ST_ALL_1day_9km/descriptionDocument.xml', 'ADEOS_OCTS_L3B_GAC_SST_1week': 'https://gpwos1.jaxa.jp/examind/api/WS/csw/ADEOS_OCTS_L3B_GAC_SST_1week/descriptionDocument.xml', 'ADEOS-II_GLI_L3B_ST_8days_9km': 'https://gpwos1.jaxa.jp/examind/api/WS/csw/ADEOS-II_GLI_L3B_ST_8days_9km/descriptionDocument.xml', 'ADEOS-II_GLI_L3B_ST_1day_9km': 'https://gpwos1.jaxa.jp/examind/api/WS/csw/ADEOS-II_GLI_L3B_ST_1day_9km/descriptionDocument.xml', 'ADEOS-II_AMSR_L3_SST_1month_0.25deg': 'https://gpwos1.jaxa.jp/examind/api/WS/csw/ADEOS-II_AMSR_L3_SST_1month_0.25deg/descriptionDocument.xml'}

2. Retrieve the Open Search Description Document (OSDD) from the result of the collection search.

[6]:
url = collections['GCOM-W_AMSR2_L2_SST']

request = urllib.request.Request(url)

with urllib.request.urlopen(request) as res:
    xml = res.read()
    root = ElementTree.fromstring( xml )

    namespaces = {"":"http://a9.com/-/spec/opensearch/1.1/"}

    node = root.find('Url', namespaces )
    template = node.attrib['template']
    netloc = urllib.parse.urlparse(template).netloc
    path = urllib.parse.urlparse(template).path
    query = urllib.parse.urlparse(template).query
    qdic = urllib.parse.parse_qs( query )

    # available params
    print( qdic )


{'service': ['CSW'], 'version': ['3.0.0'], 'request': ['GetRecords'], 'count': ['{count?}'], 'startIndex': ['{startIndex?}'], 'startPage': ['{startPage?}'], 'bbox': ['{geo:box?}'], 'geometry': ['{geo:geometry?}'], 'startTime': ['{time:start?}'], 'endTime': ['{time:end?}'], 'outputFormat': ['application/atom+xml'], 'outputSchema': ['{outputSchema?}'], 'id': ['{geo:uid?}'], 'datasetId': ['11002004'], 'prdver': ['{eo:productVersion?}'], 'orbitDirection': ['{eo:orbitDirection?}']}

3. Retrieve the download URL that corresponds to OSDD.

[ ]:
url = 'https://'+netloc+ path
params = {
    'service':qdic['service'][0],
    'version':qdic['version'][0],
    'request':qdic['request'][0],
    'outputFormat':qdic['outputFormat'][0],
    'datasetId':qdic['datasetId'][0],
    'startTime':'2021-07-07T00:00:00Z',
    'endTime':'2021-07-07T11:59:59Z',
    'bbox':'130,40,140,30'
}

query = urllib.parse.urlencode(params)

request = urllib.request.Request(url=url+'?'+query)

with urllib.request.urlopen(request) as res:
    xml = res.read()
    root = ElementTree.fromstring( xml )

    namespaces = {
        "":"http://www.w3.org/2005/Atom",
        "os":"http://a9.com/-/spec/opensearch/1.1/",
        "eop":"http://earth.esa.int/eop",
        "gml":"http://www.opengis.net/gml"
    }
    num_of_result = root.find("os:totalResults", namespaces ).text
    print( 'os:totalResults: '+num_of_result )
    product_url = []
    for node in root.findall("entry/eop:EarthObservation/gml:resultOf/eop:EarthObservationResult", namespaces ):
        product_url.append( node.find("eop:product/eop:ProductInformation/eop:fileName", namespaces).text )

    print( product_url )
os:totalResults: 1
['https://gportal.jaxa.jp/download/standard/GCOM-W/GCOM-W.AMSR2/L2.SST/4/2021/07/GW1AM2_202107070308_204A_L2SGSSTLB4400400.h5']

Reference