print

# Grab the values from 'OBJECTID' and 'upload:OKCNTYD'
usr_attribute = 'STATE'
values = pyGDP.getValues(shapefile, usr_attribute)
for v in values:
    print v
print

# our shapefile = 'upload:OKCNTYD', usr_attribute = 'OBJECTID', and usr_value = 13
# We get the dataset URI that we are interested in
dataSetURIs = pyGDP.getDataSetURI()
for d in dataSetURIs:
    print d

# Set our datasetURI
dataSetURI = 'dods://igsarm-cida-thredds1.er.usgs.gov:8080/thredds/dodsC/gmo/GMO_w_meta.ncml'
# Get the available data types associated with the dataset
dataType = 'Prcp'
# Get available time range on the dataset
timeRange = pyGDP.getTimeRange(dataSetURI, dataType)
for t in timeRange:
    print t

"""
Instead of submitting in a value, we submit a list of gmlIDs associated
with either a small portion of that value, or multiple values.
"""
values = ['Wisconsin', 'Michigan', 'Minnesota']
path = pyGDP.submitFeatureWeightedGridStatistics(shapefile, dataSetURI, dataType, timeRange[0], timeRange[0], usr_attribute, values)
print path
Exemple #2
0
# 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,
                                                       timeEnd,
                                                       usr_attribute,
                                                       usr_value,
                                                       gmlIDs=None,
                                                       verbose=True)
geoType = [(-119.871972, 34.420668), (-119.843353, 34.421090),
           (-119.844263, 34.406818), (-119.878692, 34.408690)]

baseURI = 'http://cida.usgs.gov/thredds/dodsC/loca_future'
startTime = 1950
endTime = 2100
varID = 'pr_CCSM4_r6i1p1_rcp45'

#['tasmax_CCSM4_r6i1p1_rcp45', 'tasmin_CCSM4_r6i1p1_rcp45']

years = array.array('i', (i for i in range(startTime, endTime + 1)))
fileList = []

for yr in years:
    datasetURI = '%s%s%s' % (baseURI, yr, '.nc')
    timeRange = pyGDP.getTimeRange(datasetURI, varID)
    timeStart = timeRange[0]
    timeEnd = timeRange[1]
    print "process beginning for %s on year %s'" % (varID, yr)
    outputFile_handle = pyGDP.submitFeatureWeightedGridStatistics(
        self,
        geoType,
        dataSetURI,
        varID,
        startTime,
        endTime,
        '',
        '',
        '',
        '',
        coverage='true',
            continue

    if restart_from_files:
        already_downloaded = [datatype_from_filename(f) for f in os.listdir(outpath)]
        datatypes_list = [d for d in datatypes_list if d not in already_downloaded]
        if len(datatypes_list) == 0:
            print "URI already finished"
            continue

    # could add something here to print out list of datatypes after restart    
    
    # Get time periods to run for list of datatypes
    print '\nDataTypes and timeRanges (excluding those already downloaded):'
    timeranges=[]
    for d in datatypes_list:
        timeRange = pyGDP.getTimeRange(URI, d)
        timeranges.append(timeRange)
        print '{}\t-->\t{} - {}'.format(d, timeRange[0], timeRange[1])

    # assumes that time ranges are all the same for all datatypes
    # loop to get rid of stupid empties in timeranges list
    for n in timeranges:
        try:
            timeStart = n[0]
            timeEnd = n[1]
            break
        except IndexError:
            continue    
    if TestRun: 
        # kludgy hard code to test only first timestep for wicci
        if timeStart == '1961-01-01T00:00:00Z':
          # '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
            print shapefiles[shapefile]
            datatype_from_filename(f) for f in os.listdir(outpath)
        ]
        datatypes_list = [
            d for d in datatypes_list if d not in already_downloaded
        ]
        if len(datatypes_list) == 0:
            print "URI already finished"
            continue

    # could add something here to print out list of datatypes after restart

    # Get time periods to run for list of datatypes
    print '\nDataTypes and timeRanges (excluding those already downloaded):'
    timeranges = []
    for d in datatypes_list:
        timeRange = pyGDP.getTimeRange(URI, d)
        timeranges.append(timeRange)
        print '{}\t-->\t{} - {}'.format(d, timeRange[0], timeRange[1])

    # assumes that time ranges are all the same for all datatypes
    # loop to get rid of stupid empties in timeranges list
    for n in timeranges:
        try:
            timeStart = n[0]
            timeEnd = n[1]
            break
        except IndexError:
            continue
    if TestRun:
        # kludgy hard code to test only first timestep for wicci
        if timeStart == '1961-01-01T00:00:00Z':
Exemple #7
0
# '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(