Пример #1
0
def USGS2netcdf(ncfile, meta, time, discharge):
    """
    Convert the USGS files to netcdf4 format
    """

    shpfile = ncfile[:-2] + 'shp'

    varname = 'discharge'
    longname = 'Stream Discharge Rate'
    units = 'm3 s-1'

    ncdict = []
    ii = -1
    for tt, dd in zip(time, discharge):
        ii += 1
        timeout = othertime.MinutesSince(tt, basetime=datetime(1970, 1, 1))
        ncdict=netcdfio.createObsDict(varname,longname,units,[dd],[timeout],\
                      [meta['Latitude'][ii]],[meta['Longitude'][ii]],[0.0],[meta['Station ID'][ii]],[meta['StationName'][ii]],ncdict=ncdict )

    ## Global atts
    globalatts = {'Title': 'USGS stream gage discharge data'}
    # Write to a netcdf file
    netcdfio.writePointData2Netcdf(ncfile, ncdict, globalatts)
    # Write to a shape file
    netcdfio.pointNC2shp(ncfile, shpfile)
Пример #2
0
def USGSgh2netcdf(ncfile, meta, time, gauge_height):
    """
    Convert the USGS files to netcdf4 format
    """

    shpfile = ncfile[:-2] + 'shp'

    varname = 'gauge_height'
    longname = 'Gauge height'
    units = 'm'

    ncdict = []
    ii = -1
    for tt, dd in zip(time, gauge_height):
        ii += 1
        timeout = othertime.MinutesSince(tt, basetime=datetime(1970, 1, 1))
        #ncdict=netcdfio.createObsDict(varname,longname,units,[dd],[timeout],\
        #              [meta['Latitude'][ii]],[meta['Longitude'][ii]],[0.0],[meta['Station ID'][ii]],[meta['StationName'][ii]],ncdict=ncdict )
        ncdict=netcdfio.createObsDict(varname,longname,units,[dd],[timeout],\
                      [meta['Latitude'][ii]],[meta['Longitude'][ii]],[meta['elevation'][ii]],[meta['Station ID'][ii]],[meta['StationName'][ii]],ncdict=ncdict )

    ## Global atts
    globalatts = {'Title': 'USGS gauge height data'}
    # Write to a netcdf file
    ## write to a single netcdf file with multi groups
    netcdfio.writePointData2Netcdf(ncfile, ncdict, globalatts)
    ## write to multi netcdf files
    #netcdfio.writePointData2Netcdf_new(ncfile,ncdict,globalatts)
    # Write to a shape file
    netcdfio.pointNC2shp(ncfile, shpfile)
Пример #3
0
def USGS2netcdf(ncfile,meta,time,discharge):
    """
    Convert the USGS files to netcdf4 format
    """

    
    shpfile = ncfile[:-2]+'shp'
    
    varname = 'discharge'
    longname = 'Stream Discharge Rate'
    units = 'm3 s-1'
    
    ncdict=[]
    ii=-1
    for tt,dd in zip(time,discharge):
        ii+=1
        timeout = othertime.MinutesSince(tt,basetime=datetime(1970,1,1))
        ncdict=netcdfio.createObsDict(varname,longname,units,[dd],[timeout],\
                      [meta['Latitude'][ii]],[meta['Longitude'][ii]],[0.0],[meta['Station ID'][ii]],[meta['StationName'][ii]],ncdict=ncdict )
                      
    ## Global atts
    globalatts={'Title':'USGS stream gage discharge data'}
    # Write to a netcdf file
    netcdfio.writePointData2Netcdf(ncfile,ncdict,globalatts)
    # Write to a shape file
    netcdfio.pointNC2shp(ncfile,shpfile)


#####
## Example call
#
####
## Input variables
#stationids = ['08066500',\
#            '08078000',\
#            '08067500',\
#            '08076000',\
#            '08075000',\
#            '08074500',\
#            '08076500',\
#            '08073600',\
#            '08075770']
#            
#starttime = '2000-01-01'
#endtime = '2012-01-01'
#ncfile = 'C:/Projects/GOMGalveston/DATA/River/USGS_Rivers_20002012.nc'
####
#
#getUSGSnwis(stationids,starttime,endtime,ncfile)