コード例 #1
0
import os
import sys
sys.path.append(os.environ['HOME']+'/schism/setups/scripts')
from schism import schism_setup
from pylab import *
import numpy as np
import netCDF4

s = schism_setup('hgrid.gr3')

lons = asarray([s.londict[ii] for ii in s.land_nodes ])
lats = asarray([s.latdict[ii] for ii in s.land_nodes ])
#ilats = asarray([s.latdict[ii] for ii in s.island_nodes ])
#ilons = asarray([s.londict[ii] for ii in s.island_nodes ])
num=len(lons)#+len(ilons)

nc = netCDF4.Dataset('schism_river_points.nc','w',format='NETCDF3_CLASSIC')
nc.createDimension('x',num)
nc.createDimension('y',1)

lonv = nc.createVariable('lon','f8',('y','x'))
lonv.units = 'degrees east'
lonv[:]=lons
#lonv[1:len(lons)]=lons
#lonv[len(lons):]=ilons


latv = nc.createVariable('lat','f8',('y','x'))
latv.units = 'degrees north'
latv[:]=lats
#latv[1:len(lats)]=lats
コード例 #2
0
import netCDF4
import sys,os
sys.path.append(os.environ['HOME']+'/schism/setups/scripts')
#from find_nearest_node import get_nearest_node
from schism import schism_setup,schism_output

stations=['Andenes','Honningvag','NyAlesund','Vardo']

s = schism_setup()
so = schism_output('/work/gg0877/hofmeist/arctic/arctic007/2012-02/schout_2.nc')

f = open('stations.dat','w')
f.write('# name lon lat hgrid_idx schout_idx\n')

datapath='/work/gg0877/KST/MiMeMo/tide_gaughes/'

for station in stations:
  nc = netCDF4.Dataset(datapath+station+'.nc')
  ncv = nc.variables

  lon = float(ncv['lon'][:])
  lat = float(ncv['lat'][:])

  # find index in hgrid
  hgrid_idx = s.find_nearest_node(lon,lat)
  
  # find index in output
  schout_idx = so.find_nearest_node(lon,lat)

  f.write('%s %0.3f %0.3f %d %d\n'%(station,lon,lat,hgrid_idx,schout_idx))
コード例 #3
0
import os
import sys
sys.path.append(os.environ['HOME'] + '/schism/setups/scripts')
from schism import schism_setup
from pylab import *
import numpy as np
import netCDF4

s = schism_setup('hgrid.gr3')

lons = asarray([s.londict[ii] for ii in s.land_nodes])
lats = asarray([s.latdict[ii] for ii in s.land_nodes])
#ilats = asarray([s.latdict[ii] for ii in s.island_nodes ])
#ilons = asarray([s.londict[ii] for ii in s.island_nodes ])
num = len(lons)  #+len(ilons)

nc = netCDF4.Dataset('schism_river_points.nc', 'w', format='NETCDF3_CLASSIC')
nc.createDimension('x', num)
nc.createDimension('y', 1)

lonv = nc.createVariable('lon', 'f8', ('y', 'x'))
lonv.units = 'degrees east'
lonv[:] = lons
#lonv[1:len(lons)]=lons
#lonv[len(lons):]=ilons

latv = nc.createVariable('lat', 'f8', ('y', 'x'))
latv.units = 'degrees north'
latv[:] = lats
#latv[1:len(lats)]=lats
#latv[len(lats):]=ilats