예제 #1
0
def generate_dataset_report(folder):
    '''
    Generate a descriptive report on the data included in the use case.
    
    :param folder: Path to the folder containing the NARCCAP example data.
    :type folder: str
    :returns: Path to the report file.
    :rtype: str
    '''

    ocgis.env.DIR_DATA = folder
    rds = parse_narccap_filenames(folder)
    rdc = ocgis.RequestDatasetCollection(rds)
    headers = ['DID', 'Filenames', 'Variable', 'Time Start', 'Time End']
    (fd, name) = tempfile.mkstemp(suffix='.csv')
    f = open(name, 'w')
    writer = csv.writer(f)
    writer.writerow(headers)
    for rd in rdc:
        logging.info(rd)
        ds = NcDataset(rd)
        to_write = [
            rd.did, [os.path.split(uri)[1] for uri in rd.uri], rd.variable,
            ds.temporal.value[0], ds.temporal.value[-1]
        ]
        writer.writerow(to_write)
    f.close()
    return (name)
예제 #2
0
파일: work.py 프로젝트: HydroLogic/ocgis
def generate_dataset_report(folder):
    '''
    Generate a descriptive report on the data included in the use case.
    
    :param folder: Path to the folder containing the NARCCAP example data.
    :type folder: str
    :returns: Path to the report file.
    :rtype: str
    '''
    
    ocgis.env.DIR_DATA = folder
    rds = parse_narccap_filenames(folder)
    rdc = ocgis.RequestDatasetCollection(rds)
    headers = ['DID','Filenames','Variable','Time Start','Time End']
    (fd,name) = tempfile.mkstemp(suffix='.csv')
    f = open(name,'w')
    writer = csv.writer(f)
    writer.writerow(headers)
    for rd in rdc:
        logging.info(rd)
        ds = NcDataset(rd)
        to_write = [rd.did,
                    [os.path.split(uri)[1] for uri in rd.uri],
                    rd.variable,
                    ds.temporal.value[0],
                    ds.temporal.value[-1]]
        writer.writerow(to_write)
    f.close()
    return(name)
예제 #3
0
def main():
    ## set to true to return smaller data slices - often good for debugging
    snippet = False
    ## city center coordinate (~Austin, TX)
    geom = [-97.74278,30.26694]
    ## directory to write output data. needs to exist!
    ocgis.env.DIR_OUTPUT = '/tmp/narccap'
    ## location of directory containing climate data files
    ocgis.env.DIR_DATA = '/usr/local/climate_data/narccap'
    ## write data to a common reference projection
    ocgis.env.WRITE_TO_REFERENCE_PROJECTION = True
    ## pring additional information to console
    ocgis.env.VERBOSE = True
    
    ## load the request datasets by parsing filenames on disk
    rds = parse_narccap_filenames(ocgis.env.DIR_DATA)
    ## these are the calculations to perform
    calc = [{'func':'mean','name':'mean'},
            {'func':'median','name':'median'},
            {'func':'max','name':'max'},
            {'func':'min','name':'min'}]
    ## the temporal grouping to apply when performing the computations
    calc_grouping = ['month','year']
    ## the operations object...
    ops = ocgis.OcgOperations(dataset=rds,calc=calc,calc_grouping=calc_grouping,
                              output_format='csv+',geom=geom,abstraction='point',
                              snippet=snippet)
    print(ops.execute())
예제 #4
0
def main():
    ## city center coordinate (~Austin, TX)
    geom = [-97.74278, 30.26694]
    ## directory to write output data. needs to exist!
    ocgis.env.DIR_OUTPUT = '/tmp/narccap'
    ## location of directory containing climate data files
    ocgis.env.DIR_DATA = '/usr/local/climate_data/narccap'
    ## print additional information to console
    ocgis.env.VERBOSE = True

    ## load the request datasets by parsing filenames on disk
    rds = parse_narccap_filenames(ocgis.env.DIR_DATA)
    ## these are the calculations to perform
    calc = [{'func': 'mean', 'name': 'mean'},
            {'func': 'median', 'name': 'median'},
            {'func': 'max', 'name': 'max'},
            {'func': 'min', 'name': 'min'}]
    ## the temporal grouping to apply when performing the computations
    calc_grouping = ['month', 'year']
    ## the operations object...
    ops = ocgis.OcgOperations(dataset=rds, calc=calc, calc_grouping=calc_grouping,
                              output_format='csv+', geom=geom, abstraction='point',
                              output_crs=CFWGS84)
    print(ops.execute())
예제 #5
0
def main():
    ## city center coordinate (~Austin, TX)
    geom = [-97.74278,30.26694]
    ## directory to write output data. needs to exist!
    ocgis.env.DIR_OUTPUT = '/tmp/narccap'
    ## location of directory containing climate data files
    ocgis.env.DIR_DATA = '/usr/local/climate_data/narccap'
    ## print additional information to console
    ocgis.env.VERBOSE = True
    
    ## load the request datasets by parsing filenames on disk
    rds = parse_narccap_filenames(ocgis.env.DIR_DATA)
    ## these are the calculations to perform
    calc = [{'func':'mean','name':'mean'},
            {'func':'median','name':'median'},
            {'func':'max','name':'max'},
            {'func':'min','name':'min'}]
    ## the temporal grouping to apply when performing the computations
    calc_grouping = ['month','year']
    ## the operations object...
    ops = ocgis.OcgOperations(dataset=rds,calc=calc,calc_grouping=calc_grouping,
                              output_format='csv+',geom=geom,abstraction='point',
                              output_crs=CFWGS84)
    print(ops.execute())