Skip to content

how to add a new gridded dataset to ogh #32

Description

@ChristinaB
  1. Fork Observatory
  2. Log in to CUAHSI JupyterHub server to run from HydroShare
  3. Open a terminal and

git clone http://yourfork

into a sensible folder outside of the HS folder structure (e.g. make a folder called Github)
4. copy ogh.py and ogh_meta to your HS working directory
5. test existing Notebook and functions for case study location
6. change the name and Notebook to import and use a local version of ogh and ogh meta
7. Create functions for metadata, get, and compile (A, B, C below)
8. Test and debug
9. Download your data !! Yeahhh. Explore your data with other OGH functions.
10. Click Pull request https://github.com/Freshwater-Initiative/Observatory

Three main code additions:
A. Edit ogh_meta (click here to view code) for your new dataset
B. Create a new ogh get function for your new dataset. For example, create your own version of this:

def getDailyMET_livneh2013(homedir, mappingfile,
subdir='livneh2013/Daily_MET_1915_2011/raw',
catalog_label='dailymet_livneh2013'):
"""
Get the Livneh el al., 2013 Daily Meteorology files of interest using the reference mapping file

homedir: (dir) the home directory to be used for establishing subdirectories
mappingfile: (dir) the file path to the mappingfile, which contains the LAT, LONG_, and ELEV coordinates of interest
subdir: (dir) the subdirectory to be established under homedir
catalog_label: (str) the preferred name for the series of catalogged filepaths
"""
# check and generate DailyMET livneh 2013 data directory
filedir=os.path.join(homedir, subdir)
ensure_dir(filedir)

# generate table of lats and long coordinates
maptable = pd.read_csv(mappingfile)

# compile the longitude and latitude points
locations = compile_dailyMET_Livneh2013_locations(maptable)

# Download the files
ftp_download_p(locations)

# update the mappingfile with the file catalog
addCatalogToMap(outfilepath=mappingfile, maptable=maptable, folderpath=filedir, catalog_label=catalog_label)

# return to the home directory
os.chdir(homedir)
return(filedir)

C. Create new compile function for your dataset

def compile_bc_Livneh2013_locations(maptable):
"""
Compile a list of file URLs for bias corrected Livneh et al. 2013 (CIG)

maptable: (dataframe) a dataframe that contains the FID, LAT, LONG_, and ELEV for each interpolated data file
"""
locations=[]
for ind, row in maptable.iterrows():
    basename='_'.join(['data', str(row['LAT']), str(row['LONG_'])])
    url=['http://cses.washington.edu/rocinante/Livneh/bcLivneh_WWA_2013/forcings_ascii/', basename]
    locations.append(''.join(url))
return(locations)

supp_table1.pdf

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions