Skip to content

Commit

Permalink
quick test script to explore catalog
Browse files Browse the repository at this point in the history
  • Loading branch information
aradhakrishnanGFDL committed Aug 6, 2024
1 parent 536313f commit 7c1f0ca
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
6 changes: 6 additions & 0 deletions catalogbuilder/scripts/dmget.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import os
#for simple dmget usage, just use this !dmget {file}
#use following to wrap the dmget call for each path in the catalog
def dmgetmagic(x):
cmd = 'dmget %s'% str(x)
return os.system(cmd)
28 changes: 28 additions & 0 deletions catalogbuilder/scripts/getdatasets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import intake_esm, intake, dmget
cat = "/home/a1r/github/noaa-gfdl/catalogs/c96L65_am5f7b10r0_amip30_0806.json"
col = intake.open_esm_datastore(cat)
print("Dataframe summary")
print("---------------------")
print(col.df)
#lets search
freq = "day"
cfname = "air_temperature"
esmcat = col.search(frequency = freq, standard_name = cfname)
print("Search results in:")
print("---------------------")
print(esmcat)
##dmget data
print("dmgetting")
print("---------------------")
dmstatus = esmcat.df["path"].apply(dmget.dmgetmagic)
print("dgmet status")
print("---------------------")
dmstatus = esmcat.df["path"].apply(dmget.dmgetmagic)
print(dmstatus)
print("Aggregating and creating a dictionary with dataset names as keys and the values as the xarray dataset object")
dset_dict = esmcat.to_dataset_dict(cdf_kwargs={'chunks': {'time':5}, 'decode_times': False})
print("print dataset keys/names")
print("---------------------")
for k in dset_dict.keys():
print(k)

0 comments on commit 7c1f0ca

Please sign in to comment.