This Jupyter notebook demonstrates using the cdasws and hdpws Python packages to obtain uri-template values for CDAWeb datasets. It assumes some familarity with the SPASE data model. This notebook contains the following sections:
Install the prerequisite software from Python Package Index (PyPI) software repository.
Execute some preliminary code that is necessary before the code that follows.
from hdpws.hdpws import HdpWs
from hdpws import NAMESPACES as NS
from hdpws.spase import AccessURL
from cdasws import CdasWs
from IPython.display import HTML
hdp = HdpWs()
cdas = CdasWs()
dataset_descriptions = cdas.get_datasets()
html = '<table><caption>CDAWeb Datasets</caption><tr><th>Identifier</th><th>Directory Template</th><th>Filename Template</th></tr>'
for dataset in dataset_descriptions[0:9]:
identifier = dataset['Id']
if 'SpaseResourceId' in dataset:
spase_id = dataset['SpaseResourceId']
result = hdp.get_spase([spase_id])
if result['HttpStatus'] == 200:
spase = result['Result'].findall('.//Spase', namespaces=NS)[0]
cdaweb_access_information = \
spase.find('.//AccessURL[Name="CDAWeb"]/..', namespaces=NS)
if cdaweb_access_information is not None:
dir_template = cdaweb_access_information.find('./AccessDirectoryTemplate',
namespaces=NS)
file_template = cdaweb_access_information.find('./AccessFilenameTemplate',
namespaces=NS)
if dir_template is not None and file_template is not None:
#print(f'{identifier} "{dir_template.text}" {file_template.text}')
html += f'<tr><td>{identifier}</td><td><pre>{dir_template.text}</pre></td><td><pre>{file_template.text}<pre></td></tr>'
else:
print(f'failed to find templates for {spase_id}')
print(cdaweb_access_information)
else:
print(f'failed to find cdaweb access information for {spase_id}')
else:
print(f'failed to get spase for {spase_id}')
html += '</table>'
display(HTML(html))
Identifier | Directory Template | Filename Template |
---|---|---|
A1_K0_MPA | https://cdaweb.gsfc.nasa.gov/pub/data/lanl/01a_mpa/$Y | a1_k0_mpa_$Y$m$d_$v.cdf |
A2_K0_MPA | https://cdaweb.gsfc.nasa.gov/pub/data/lanl/02a_mpa/$Y | a2_k0_mpa_$Y$m$d_$v.cdf |
AC_AT_DEF | https://cdaweb.gsfc.nasa.gov/pub/data/ace/orbit/level_2_cdaweb/def_at/$Y | ac_at_def_$Y$m$d_$v.cdf |
AC_H0_MFI | https://cdaweb.gsfc.nasa.gov/pub/data/ace/mag/level_2_cdaweb/mfi_h0/$Y | ac_h0_mfi_$Y$m$d_$v.cdf |
AC_H0_SWE | https://cdaweb.gsfc.nasa.gov/pub/data/ace/swepam/level_2_cdaweb/swe_h0/$Y | ac_h0_swe_$Y$m$d_$v.cdf |
AC_H1_EPM | https://cdaweb.gsfc.nasa.gov/pub/data/ace/epam/level_2_cdaweb/epm_h1/$Y | ac_h1_epm_$Y$m$d_$v.cdf |
AC_H1_MFI | https://cdaweb.gsfc.nasa.gov/pub/data/ace/mag/level_2_cdaweb/mfi_h1/$Y | ac_h1_mfi_$Y$m$d_$v.cdf |
AC_H1_SIS | https://cdaweb.gsfc.nasa.gov/pub/data/ace/sis/level_2_cdaweb/sis_h1/$Y | ac_h1_sis_$Y$m$d_$v.cdf |
AC_H2_CRIS | https://cdaweb.gsfc.nasa.gov/pub/data/ace/cris/level_2_cdaweb/cris_h2/$Y | ac_h2_cris_$Y$m$d_$v.cdf |