Ejemplo n.º 1
0
  outdata.createVariable('ndays','i4',('time',))[:] = days_per_month
  # names of months (as char array)
  coord = outdata.createVariable('month','S1',('time','tstrlen'))
  for m in xrange(ntime): 
    for n in xrange(9): coord[m,n] = months[m][n]
  # global attributes
  outdata.description = 'Climatology of GPCC monthly precipitation, averaged from %04i to %04i'%(debyr,finyr)
  outdata.creator = 'Andre R. Erler' 
  copy_ncatts(outdata,indata['rain'],prefix='GPCC_')
  # create old lat/lon dimensions and coordinate variables
  copy_dims(outdata, indata['rain'], dimlist=dimlist.keys(), namemap=dimlist, copy_coords=True)
  # create climatology variables  
  dims = ('time','lat','lon'); fill_value = -9999
  # precipitation
  atts = dict(long_name='Precipitation', units='mm/day')
  add_var(outdata, 'rain', dims, values=climdata['rain'].filled(fill_value), atts=atts, fill_value=fill_value)
  # station density
  atts = dict(long_name='Station Density', units='#')
  add_var(outdata, 'stns', dims, values=climdata['stns'].filled(fill_value), atts=atts, fill_value=fill_value)  
  # land mask
  atts = dict(long_name='Land Mask', units='')
  tmp = ma.masked_array(ma.ones((datashape[1],datashape[2])), mask=dataMask)
  add_var(outdata, 'landmask', ('lat','lon'), values=tmp.filled(0))
  
#   ## dataset feedback and diagnostics
#   # print dataset meta data
#   print('\n\n')
#   print(outdata)
#   # print dimensions meta data
#   for dimobj in outdata.dimensions.values():
#     print dimobj
Ejemplo n.º 2
0
    # names of months (as char array)
    coord = outdata.createVariable('month','S1',('time','tstrlen'))
    for m in xrange(ntime): 
      for n in xrange(9): coord[m,n] = months[m][n]
    # global attributes
    outdata.description = 'Climatology of monthly PRISM data'
    outdata.creator = 'Andre R. Erler' 
    
#     copy_ncatts(outdata,indata['rain'],prefix='GPCC_')
    # create new lat/lon dimensions and coordinate variables
    add_coord(outdata, 'lat', values=lat, atts=None)
    add_coord(outdata, 'lon', values=lon, atts=None)
    # create climatology variables  
    fill_value = -9999
    atts = dict(long_name='Precipitation', units='mm/day')
    add_var(outdata, 'rain', ('time','lat','lon'), values=ppt.filled(fill_value), atts=atts, fill_value=fill_value)
    atts = dict(long_name='Minimum Temperature', units='deg. C')
    add_var(outdata, 'Tmin', ('time','lat','lon'), values=Tmin.filled(fill_value), atts=atts, fill_value=fill_value)
    atts = dict(long_name='Average Temperature', units='deg. C')
    add_var(outdata, 'T2', ('time','lat','lon'), values=Tavg.filled(fill_value), atts=atts, fill_value=fill_value)
    atts = dict(long_name='Maximum Temperature', units='deg. C')
    add_var(outdata, 'Tmax', ('time','lat','lon'), values=Tmax.filled(fill_value), atts=atts, fill_value=fill_value)
    
    # dataset feedback and diagnostics
    # print dataset meta data
    print outdata
    # print dimensions meta data
    for dimobj in outdata.dimensions.values():
      print dimobj
    # print variable meta data
    for varobj in outdata.variables.values():
Ejemplo n.º 3
0
 outdata.createVariable('ndays','i4',('time',))[:] = days_per_month
 # names of months (as char array)
 coord = outdata.createVariable('month','S1',('time','tstrlen'))
 for m in xrange(ntime): 
   for n in xrange(9): coord[m,n] = months[m][n]
 # global attributes
 outdata.description = 'Climatology of CRU monthly climate data, averaged from %04i to %04i'%(debyr,finyr)
 outdata.creator = 'Andre R. Erler' 
 copy_ncatts(outdata,indata['rain'],prefix='CRU_')
 # create old lat/lon dimensions and coordinate variables
 copy_dims(outdata, indata['rain'], dimlist=dimlist.keys(), namemap=dimlist, copy_coords=True)
 # create climatology variables  
 dims = ('time','lat','lon'); fill_value = -9999
 # precipitation
 atts = dict(long_name='Precipitation', units='mm/day')
 add_var(outdata, 'rain', dims, values=climdata['rain'].filled(fill_value), atts=atts, fill_value=fill_value)
 # 2m mean Temperature
 atts = dict(long_name='Temperature at 2m', units='K')
 add_var(outdata, 'T2', dims, values=climdata['T2'].filled(fill_value), atts=atts, fill_value=fill_value)  
 # 2m maximum Temperature
 atts = dict(long_name='Maximum 2m Temperature', units='K')
 add_var(outdata, 'Tmax', dims, values=climdata['Tmax'].filled(fill_value), atts=atts, fill_value=fill_value)  
 # 2m minimum Temperature
 atts = dict(long_name='Minimum 2m Temperature', units='K')
 add_var(outdata, 'Tmin', dims, values=climdata['Tmin'].filled(fill_value), atts=atts, fill_value=fill_value)  
 # 2m water vapor
 atts = dict(long_name='Water Vapor Pressure at 2m', units='hPa')
 add_var(outdata, 'Q2', dims, values=climdata['Q2'].filled(fill_value), atts=atts, fill_value=fill_value)  
 # land mask
 atts = dict(long_name='Land Mask', units='')
 tmp = ma.masked_array(ma.ones((datashape[1],datashape[2])), mask=dataMask)
Ejemplo n.º 4
0
    outdata.creator = 'Andre R. Erler'
    copy_ncatts(outdata, indata['rain'], prefix='GPCC_')
    # create old lat/lon dimensions and coordinate variables
    copy_dims(outdata,
              indata['rain'],
              dimlist=dimlist.keys(),
              namemap=dimlist,
              copy_coords=True)
    # create climatology variables
    dims = ('time', 'lat', 'lon')
    fill_value = -9999
    # precipitation
    atts = dict(long_name='Precipitation', units='mm/day')
    add_var(outdata,
            'rain',
            dims,
            values=climdata['rain'].filled(fill_value),
            atts=atts,
            fill_value=fill_value)
    # station density
    atts = dict(long_name='Station Density', units='#')
    add_var(outdata,
            'stns',
            dims,
            values=climdata['stns'].filled(fill_value),
            atts=atts,
            fill_value=fill_value)
    # land mask
    atts = dict(long_name='Land Mask', units='')
    tmp = ma.masked_array(ma.ones((datashape[1], datashape[2])), mask=dataMask)
    add_var(outdata, 'landmask', ('lat', 'lon'), values=tmp.filled(0))