-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conflicts: sh/build_documentation.sh
- Loading branch information
Showing
160 changed files
with
19,344 additions
and
10,312 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,53 @@ | ||
from ocgis import OcgOperations, RequestDataset, RequestDatasetCollection, env | ||
import os.path | ||
|
||
from ocgis import OcgOperations, RequestDataset, RequestDatasetCollection, env | ||
|
||
|
||
## Directory holding climate data. | ||
# Directory holding climate data. | ||
DATA_DIR = '/usr/local/climate_data/CanCM4' | ||
## Filename to variable name mapping. | ||
NCS = {'tasmin_day_CanCM4_decadal2000_r2i1p1_20010101-20101231.nc':'tasmin', | ||
'tas_day_CanCM4_decadal2000_r2i1p1_20010101-20101231.nc':'tas', | ||
'tasmax_day_CanCM4_decadal2000_r2i1p1_20010101-20101231.nc':'tasmax'} | ||
## Always start with a snippet (if there are no calculations!). | ||
# Filename to variable name mapping. | ||
NCS = {'tasmin_day_CanCM4_decadal2000_r2i1p1_20010101-20101231.nc': 'tasmin', | ||
'tas_day_CanCM4_decadal2000_r2i1p1_20010101-20101231.nc': 'tas', | ||
'tasmax_day_CanCM4_decadal2000_r2i1p1_20010101-20101231.nc': 'tasmax'} | ||
# Always start with a snippet (if there are no calculations!). | ||
SNIPPET = True | ||
## Data returns will overwrite in this case. Use with caution!! | ||
# Data returns will overwrite in this case. Use with caution!! | ||
env.OVERWRITE = True | ||
|
||
|
||
## RequestDatasetCollection #################################################### | ||
# RequestDatasetCollection ############################################################################################# | ||
|
||
rdc = RequestDatasetCollection([RequestDataset( | ||
os.path.join(DATA_DIR,uri),var) for uri,var in NCS.iteritems()]) | ||
os.path.join(DATA_DIR, uri), var) for uri, var in NCS.iteritems()]) | ||
|
||
## Return In-Memory ############################################################ | ||
# Return In-Memory ##################################################################################################### | ||
|
||
## Data is returned as a dictionary-like object (SpatialCollection) with 51 keys | ||
## (don't forget Puerto Rico...). A key in the returned dictionary corresponds | ||
## to a geometry "ugid" with the value of type OcgCollection. | ||
# Data is returned as a dictionary-like object (SpatialCollection) with 51 keys (don't forget Puerto Rico...). A key in | ||
# the returned dictionary corresponds to a geometry "ugid" with the value of type OcgCollection. | ||
print('returning numpy...') | ||
ops = OcgOperations(dataset=rdc,spatial_operation='clip',aggregate=True, | ||
snippet=SNIPPET,geom='state_boundaries') | ||
ops = OcgOperations(dataset=rdc, spatial_operation='clip', aggregate=True, snippet=SNIPPET, geom='state_boundaries') | ||
ret = ops.execute() | ||
|
||
## Return a SpatialCollection, but only for a target state in a U.S. state | ||
## boundaries shapefile. In this case, the UGID attribute value of 23 is associated | ||
## with Nebraska. | ||
# Return a SpatialCollection, but only for a target state in a U.S. state boundaries shapefile. In this case, the UGID | ||
# attribute value of 23 is associated with Nebraska. | ||
|
||
print('returning numpy for a state...') | ||
ops = OcgOperations(dataset=rdc,spatial_operation='clip',aggregate=True, | ||
snippet=SNIPPET,geom='state_boundaries',select_ugid=[23]) | ||
ops = OcgOperations(dataset=rdc, spatial_operation='clip', aggregate=True, snippet=SNIPPET, geom='state_boundaries', | ||
select_ugid=[23]) | ||
ret = ops.execute() | ||
|
||
## Write to Shapefile ########################################################## | ||
# Write to Shapefile ################################################################################################### | ||
|
||
print('returning shapefile...') | ||
ops = OcgOperations(dataset=rdc,spatial_operation='clip',aggregate=True, | ||
snippet=SNIPPET,geom='state_boundaries',output_format='shp') | ||
ops = OcgOperations(dataset=rdc, spatial_operation='clip', aggregate=True, snippet=SNIPPET, geom='state_boundaries', | ||
output_format='shp') | ||
path = ops.execute() | ||
|
||
## Write All Data to Keyed Format ############################################## | ||
# Write All Data to Keyed Format ####################################################################################### | ||
|
||
## Without the snippet, we are writing all data to the linked CSV-Shapefile | ||
## output format. The operation will take considerably longer. | ||
print('returning csv+...') | ||
ops = OcgOperations(dataset=rdc,spatial_operation='clip',aggregate=True, | ||
snippet=False,geom='state_boundaries',output_format='csv+') | ||
# Without the snippet, we are writing all data to the linked CSV-Shapefile output format. The operation will take | ||
# considerably longer. | ||
print('returning csv-shp...') | ||
ops = OcgOperations(dataset=rdc, spatial_operation='clip', aggregate=True, snippet=False, geom='state_boundaries', | ||
output_format='csv-shp') | ||
path = ops.execute() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,39 @@ | ||
import ocgis | ||
import os | ||
|
||
import ocgis | ||
|
||
|
||
|
||
## Directory holding climate data. | ||
# Directory holding climate data. | ||
DATA_DIR = '/usr/local/climate_data/CanCM4' | ||
## Location and variable name for a daily decadal temperature simulation. | ||
URI_TAS = os.path.join(DATA_DIR,'tas_day_CanCM4_decadal2000_r2i1p1_20010101-20101231.nc') | ||
# Location and variable name for a daily decadal temperature simulation. | ||
URI_TAS = os.path.join(DATA_DIR, 'tas_day_CanCM4_decadal2000_r2i1p1_20010101-20101231.nc') | ||
VAR_TAS = 'tas' | ||
## Make it easy to switch to non-snippet requests. | ||
# Make it easy to switch to non-snippet requests. | ||
SNIPPET = True | ||
## Set output directory for shapefile and keyed formats. (MAKE SURE IT EXISTS!) | ||
# Set output directory for shapefile and keyed formats. (MAKE SURE IT EXISTS!) | ||
ocgis.env.DIR_OUTPUT = '/tmp/foo' | ||
os.mkdir('/tmp/foo') | ||
## The bounding box coordinates [minx, miny, maxx, maxy] for the state of | ||
## Colorado in WGS84 latitude/longitude coordinates. | ||
# The bounding box coordinates [minx, miny, maxx, maxy] for the state of Colorado in WGS84 latitude/longitude | ||
# coordinates. | ||
BBOX = [-109.1, 36.9, -102.0, 41.0] | ||
|
||
|
||
## Construct RequestDataset Object ############################################# | ||
# Construct RequestDataset Object ###################################################################################### | ||
|
||
## This object will be reused so just build it once. | ||
rd = ocgis.RequestDataset(URI_TAS,VAR_TAS) | ||
# This object will be reused so just build it once. | ||
rd = ocgis.RequestDataset(URI_TAS, VAR_TAS) | ||
|
||
## Returning NumPy Data Objects ################################################ | ||
# Returning NumPy Data Objects ######################################################################################### | ||
|
||
## The NumPy data type return is the default. Only the geometry and | ||
## RequestDataset are required (except "snippet" of course...). See the | ||
## documentation for the OcgCollection object to understand the return | ||
## structure. | ||
ret = ocgis.OcgOperations(dataset=rd,geom=BBOX,snippet=SNIPPET).execute() | ||
# The NumPy data type return is the default. Only the geometry and RequestDataset are required (except "snippet" of | ||
# course...). See the documentation for the OcgCollection object to understand the return structure. | ||
ret = ocgis.OcgOperations(dataset=rd, geom=BBOX, snippet=SNIPPET).execute() | ||
|
||
## Returning Converted Files ################################################### | ||
# Returning Converted Files ############################################################################################ | ||
|
||
output_formats = ['shp','csv','csv+','nc'] | ||
output_formats = ['shp', 'csv', 'csv-shp', 'nc'] | ||
for output_format in output_formats: | ||
prefix = output_format + '_output' | ||
ops = ocgis.OcgOperations(dataset=rd,geom=BBOX,snippet=SNIPPET, | ||
output_format=output_format,prefix=prefix) | ||
ops = ocgis.OcgOperations(dataset=rd, geom=BBOX, snippet=SNIPPET, output_format=output_format, prefix=prefix) | ||
ret = ops.execute() |
Oops, something went wrong.