예제 #1
0
# Grab the file and get its attributes:
shapefile = 'sample:CSC_Boundaries'
attributes = pyGDP.getAttributes(shapefile)
for attr in attributes:
    print(attr)

# Grab the values from 'area_name' and 'sample:CSC_Boundaries'
usr_attribute = 'area_name'
values = pyGDP.getValues(shapefile, usr_attribute)
for v in values:
    print(v)

usr_value = 'Southwest'

dataSetURI = 'dods://cida.usgs.gov/thredds/dodsC/gmo/GMO_w_meta.ncml'
dataTypes = pyGDP.getDataType(dataSetURI)
for d in dataTypes:
    print(d)

dataType = 'Prcp'
# Get available time range on the dataset
timeRange = pyGDP.getTimeRange(dataSetURI, dataType)
for t in timeRange:
    print(t)

timeBegin = '1960-01-01T00:00:00.000Z'
timeEnd = '1960-01-21T00:00:00.000Z'
outputPath = pyGDP.submitFeatureWeightedGridStatistics(shapefile,
                                                       dataSetURI,
                                                       dataType,
                                                       timeBegin,
예제 #2
0
# In[19]:

usr_attribute="hru_id"
usr_values=None
#usr_values = pyGDP.getValues(shapefile, usr_attribute)
#for v in values:
#    print v


# In[7]:

# Set our datasetURI
#dataSetURI = 'dods://cida.usgs.gov/thredds/dodsC/prism'
dataSetURI = 'http://thredds.daac.ornl.gov/thredds/dodsC/daymet-agg/daymet-agg.ncml'
# Get the available data types associated with the dataset
datatypes = pyGDP.getDataType(dataSetURI)
for dt in datatypes:
	print dt


# In[9]:

# Set the dataType. Note that leaving dataType out below will select all.
# Get available time range on the dataset
dataType='prcp'
timeRange = pyGDP.getTimeRange(dataSetURI, dataType)
for t in timeRange:
    print t


# In[14]:
예제 #3
0
else:
    ofp.write('CIDA_output_handle, datatype\n')

# Loop through the datasets (Time periods)
print '\nGetting DataTypes for each URI...'
for URI in dataSetURIs:

    # Get list of datatypes based on realization and parameters specified above
    datatypes_list = []
    
    # in case the server bombs out, try again
    dTypes = False
    while not dTypes:
        try:
            print '\n{}'.format(URI)
            dataTypes = pyGDP.getDataType(URI)
            dTypes = True

        except Exception, e:
            print e
            print "trying again in a moment..."
            time.sleep(5)
            print "asking again for dataTypes..."
    
    if len(dataTypes) == 0:
        print "Error! no datasets returned."

    for d in dataTypes:
        for p in parameters:
            if realization in d and p in d:
                datatypes_list.append(d)
          # 'http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/ncml/days_prcp_abv_cmip5_der.ncml',
          # 'http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/ncml/cooling_degree_day_cmip5_der.ncml',
          # 'http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/ncml/longest_run_tmax_abv_cmip5_hist_der.ncml',
          # 'http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/ncml/longest_run_prcp_blw_cmip5_hist_der.ncml',
          # 'http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/ncml/heating_degree_day_cmip5_hist_der.ncml',
          # 'http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/ncml/growing_season_lngth_cmip5_hist_der.ncml',
          # 'http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/ncml/growing_degree_day_cmip5_hist_der.ncml',
          # 'http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/ncml/days_tmin_blw_cmip5_hist_der.ncml',
          # 'http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/ncml/days_tmax_abv_cmip5_hist_der.ncml',
          # 'http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/ncml/days_prcp_abv_cmip5_hist_der.ncml',
          # 'http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/ncml/cooling_degree_day_cmip5_hist_der.ncml']

for dataURI in dataURIs:
    remote_dataURI=dataURI.replace('http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/','http://cida-eros-thredds3.er.usgs.gov:8080/thredds/dodsC/cmip5_bcca/derivatives/')
    print(remote_dataURI)
    dataTypes = pyGDP.getDataType(remote_dataURI)
    timeRange = pyGDP.getTimeRange(remote_dataURI, dataTypes[0])
    if len(dataTypes)==1:
        dataTypes=dataTypes[0]
    for shapefile in shapefiles.keys():
        outputfilename=shapefile.replace('derivative:','')+'_'+dataURI.replace('http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/ncml/','')
        outputfilename=outputfilename.replace('http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/averages_rcp/ncml/','')
        outputfilename=outputfilename.replace('http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/averages_hist/ncml/','')
        outputfilename=outputfilename.replace('http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/averages_gmo/ncml/','')
        outputfilename=outputfilename.replace('http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/cmip5_obs_der/','')
        if not os.path.isfile(outputfilename):
            open(outputfilename, 'a').close()
            print shapefile
            print dataURI
            print dataTypes
            print timeRange
예제 #5
0
else:
    ofp.write('CIDA_output_handle, datatype\n')

# Loop through the datasets (Time periods)
print '\nGetting DataTypes for each URI...'
for URI in dataSetURIs:

    # Get list of datatypes based on realization and parameters specified above
    datatypes_list = []

    # in case the server bombs out, try again
    dTypes = False
    while not dTypes:
        try:
            print '\n{}'.format(URI)
            dataTypes = pyGDP.getDataType(URI)
            dTypes = True

        except Exception, e:
            print e
            print "trying again in a moment..."
            time.sleep(5)
            print "asking again for dataTypes..."

    if len(dataTypes) == 0:
        print "Error! no datasets returned."

    for d in dataTypes:
        for p in parameters:
            if realization in d and p in d:
                datatypes_list.append(d)
예제 #6
0
# 'http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/ncml/longest_run_prcp_blw_cmip5_hist_der.ncml',
# 'http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/ncml/heating_degree_day_cmip5_hist_der.ncml',
# 'http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/ncml/growing_season_lngth_cmip5_hist_der.ncml',
# 'http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/ncml/growing_degree_day_cmip5_hist_der.ncml',
# 'http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/ncml/days_tmin_blw_cmip5_hist_der.ncml',
# 'http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/ncml/days_tmax_abv_cmip5_hist_der.ncml',
# 'http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/ncml/days_prcp_abv_cmip5_hist_der.ncml',
# 'http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/ncml/cooling_degree_day_cmip5_hist_der.ncml']

for dataURI in dataURIs:
    remote_dataURI = dataURI.replace(
        'http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/',
        'http://cida-eros-thredds3.er.usgs.gov:8080/thredds/dodsC/cmip5_bcca/derivatives/'
    )
    print(remote_dataURI)
    dataTypes = pyGDP.getDataType(remote_dataURI)
    timeRange = pyGDP.getTimeRange(remote_dataURI, dataTypes[0])
    if len(dataTypes) == 1:
        dataTypes = dataTypes[0]
    for shapefile in shapefiles.keys():
        outputfilename = shapefile.replace(
            'derivative:', ''
        ) + '_' + dataURI.replace(
            'http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/ncml/',
            '')
        outputfilename = outputfilename.replace(
            'http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/averages_rcp/ncml/',
            '')
        outputfilename = outputfilename.replace(
            'http://localhost:8080/thredds/dodsC/Scratch/thredds/bcca/bcca/cmip5/derivatives/averages_hist/ncml/',
            '')