source: TOOLS/MOSAIX/cotes_etal.py @ 4172

Last change on this file since 4172 was 4172, checked in by omamce, 3 years ago

O.M. :

  • More documentation
  • Update run-off weights computation
  • Update calving weights computation
  • Property svn:keywords set to Date Revision HeadURL Author Id
File size: 20.0 KB
Line 
1# -*- Mode: python -*-
2### ===========================================================================
3###
4### Compute runoff weights.
5### For LMDZ only. Not suitable for DYNAMICO
6###
7### ===========================================================================
8##
9##  Warning, to install, configure, run, use any of Olivier Marti's
10##  software or to read the associated documentation you'll need at least
11##  one (1) brain in a reasonably working order. Lack of this implement
12##  will void any warranties (either express or implied).
13##  O. Marti assumes no responsability for errors, omissions,
14##  data loss, or any other consequences caused directly or indirectly by
15##  the usage of his software by incorrectly or partially configured
16##  personal.
17##
18# SVN information
19__Author__   = "$Author$"
20__Date__     = "$Date$"
21__Revision__ = "$Revision$"
22__Id__       = "$Id$"
23__HeadURL__  = "$HeadURL$"
24__SVN_Date__ = "$SVN_Date: $"
25##
26
27## Modules
28import netCDF4
29import numpy as np
30import nemo
31from scipy import ndimage
32import sys, os, platform, argparse, textwrap, time
33
34## Userful constants
35zero    = np.dtype('float64').type(0.0)
36zone    = np.dtype('float64').type(1.0)
37epsfrac = np.dtype('float64').type(1.0E-10)
38pi      = np.pi
39rad     = pi/np.dtype('float64').type(180.0)
40ra      = np.dtype('float64').type(6371229.0) # Earth radius
41
42## Functions
43def geodist (plon1, plat1, plon2, plat2) :
44      """Distance between two points (on sphere)"""
45      zs = np.sin (rad*plat1) * np.sin (rad*plat2) +  np.cos (rad*plat1) * np.cos (rad*plat2) * np.cos(rad*(plon2-plon1))
46      zs = np.maximum (-zone, np.minimum (zone, zs))
47      geodist =  np.arccos (zs)
48      return geodist
49
50### ===== Reading command line parameters ==================================================
51# Creating a parser
52parser = argparse.ArgumentParser (
53    description = """Compute calving weights""",
54    epilog='-------- End of the help message --------')
55
56# Adding arguments
57parser.add_argument ('--oce'          , help='oce model name', type=str, default='eORCA1.2', choices=['ORCA2.3', 'eORCA1.2', 'eORCA025'] )
58parser.add_argument ('--atm'          , help='atm model name (LMD*)', type=str, default='LMD9695'    )
59parser.add_argument ('--atmCoastWidth', help='width of the coastal band in atmosphere (in grid points)', type=int, default=1 )
60parser.add_argument ('--oceCoastWidth', help='width of the coastal band in ocean (in grid points)'     , type=int, default=2 )
61parser.add_argument ('--searchRadius' , help='max distance to connect a land point to an ocean point (in km)', type=float, default=600000.0)
62parser.add_argument ('--grids' , help='grids file name', default='grids.nc' )
63parser.add_argument ('--areas' , help='masks file name', default='areas.nc' )
64parser.add_argument ('--masks' , help='areas file name', default='masks.nc' )
65parser.add_argument ('--o2a'   , help='o2a file name'  , default='o2a.nc' )
66parser.add_argument ('--output', help='output rmp file name', default='rmp_tlmd_to_torc_runoff_64bit.nc' )
67parser.add_argument ('--fmt'   , help='NetCDF file format, using nco syntax', default='64bit', choices=['classic', 'netcdf3', '64bit', '64bit_data', '64bit_data', 'netcdf4', 'netcdf4_classsic'] )
68
69# Parse command line
70myargs = parser.parse_args()
71
72#
73grids = myargs.grids
74areas = myargs.areas
75masks = myargs.masks
76o2a   = myargs.o2a
77
78# Model Names
79atm_Name = myargs.atm
80oce_Name = myargs.oce
81# Width of the coastal band (land points) in the atmopshere
82atmCoastWidth = myargs.atmCoastWidth
83# Width of the coastal band (ocean points) in the ocean
84oceCoastWidth = myargs.oceCoastWidth
85searchRadius  = myargs.searchRadius * 1000.0 # From km to meters
86# Netcdf format
87if myargs.fmt == 'classic'         : FmtNetcdf = 'CLASSIC'
88if myargs.fmt == 'netcdf3'         : FmtNetcdf = 'CLASSIC'
89if myargs.fmt == '64bit'           : FmtNetcdf = 'NETCDF3_64BIT_OFFSET'
90if myargs.fmt == '64bit_data'      : FmtNetcdf = 'NETCDF3_64BIT_DATA'
91if myargs.fmt == '64bit_offset'    : FmtNetcdf = 'NETCDF3_64BIT_OFFSET'
92if myargs.fmt == 'netcdf4'         : FmtNetcdf = 'NETCDF4'
93if myargs.fmt == 'netcdf4_classic' : FmtNetcdf = 'NETCDF4_CLASSIC'
94
95### Read coordinates of all models
96###
97
98diaFile    = netCDF4.Dataset ( o2a   )
99gridFile   = netCDF4.Dataset ( grids )
100areaFile   = netCDF4.Dataset ( areas )
101maskFile   = netCDF4.Dataset ( masks )
102
103o2aFrac             = diaFile ['OceFrac'][:].squeeze()
104o2aFrac = np.where ( np.abs(o2aFrac) < 1E10, o2aFrac, 0.0)
105
106atm_grid_center_lat = gridFile['tlmd.lat'][:]
107atm_grid_center_lon = gridFile['tlmd.lon'][:]
108atm_grid_corner_lat = gridFile['tlmd.cla'][:]
109atm_grid_corner_lon = gridFile['tlmd.clo'][:]
110
111atm_grid_area       = areaFile['tlmd.srf'][:]
112atm_grid_imask      = 1-maskFile['tlmd.msk'][:].squeeze()
113atm_grid_dims       = atm_grid_area.shape
114(atm_nvertex, atm_jpj, atm_jpi) = atm_grid_corner_lat.shape
115atm_perio = 0
116atm_grid_pmask = nemo.lbc_mask (atm_grid_imask, 'T', atm_perio)
117atm_address = np.reshape ( np.arange(atm_jpj*atm_jpi), (atm_jpj, atm_jpi) )
118atm_grid_size = atm_jpj*atm_jpi
119
120oce_grid_center_lat = gridFile['torc.lat'][:]
121oce_grid_center_lon = gridFile['torc.lon'][:]
122oce_grid_corner_lat = gridFile['torc.cla'][:]
123oce_grid_corner_lon = gridFile['torc.clo'][:]
124oce_grid_area       = areaFile['torc.srf'][:]
125oce_grid_imask      = 1-maskFile['torc.msk'][:]
126oce_grid_dims       = oce_grid_area.shape
127(oce_nvertex, oce_jpj, oce_jpi) = oce_grid_corner_lat.shape ; jpon=oce_jpj*oce_jpj
128if oce_jpi ==  182 : oce_perio = 4 # ORCA 2
129if oce_jpi ==  362 : oce_perio = 6 # ORCA 1
130if oce_jpi == 1442 : oce_perio = 6 # ORCA 025
131oce_grid_pmask = nemo.lbc_mask (oce_grid_imask, 'T', oce_perio)
132oce_address = np.reshape ( np.arange(oce_jpj*oce_jpi), (oce_jpj, oce_jpi) )
133oce_grid_size = oce_jpj*oce_jpi
134
135## Fill closed sea with image processing library
136oce_grid_imask = nemo.lbc_mask ( 1-ndimage.binary_fill_holes (1-nemo.lbc(oce_grid_imask, nperio=oce_perio, cd_type='T')), nperio=oce_perio, cd_type='T' )
137
138##
139print ("Determination d'une bande cotiere ocean")
140
141oceLand  = np.where (oce_grid_pmask[:] < 0.5, True, False)
142oceOcean = np.where (oce_grid_pmask[:] > 0.5, True, False)
143
144NNocean = 1+2*oceCoastWidth
145oceOceanFiltered = ndimage.uniform_filter(oceOcean.astype(float), size=NNocean)
146oceCoast = np.where (oceOceanFiltered<(1.0-0.5/(NNocean**2)),True,False) & oceOcean
147oceCoast = nemo.lbc_mask (oceCoast, oce_perio, 'T')
148
149print ('Number of points in oceLand  : ' + str(oceLand.sum()) )
150print ('Number of points in oceOcean : ' + str(oceOcean.sum()) )
151print ('Number of points in oceCoast : ' + str(oceCoast.sum()) )
152
153# Arrays with coastal points only
154oceCoast_grid_center_lon = oce_grid_center_lon[oceCoast]
155oceCoast_grid_center_lat = oce_grid_center_lat[oceCoast]
156oceCoast_grid_area       = oce_grid_area      [oceCoast]
157oceCoast_grid_imask      = oce_grid_imask     [oceCoast]
158oceCoast_grid_pmask      = oce_grid_pmask     [oceCoast]
159oceCoast_address         = oce_address        [oceCoast]
160
161print ("Determination d'une bande cotiere atmosphere " )
162atmLand      = np.where (o2aFrac[:] < epsfrac       , True, False)
163atmLandFrac  = np.where (o2aFrac[:] < zone-epsfrac  , True, False)
164atmFrac      = np.where (o2aFrac[:] > epsfrac       , True, False) & np.where (o2aFrac[:] < (zone-epsfrac), True, False)
165atmOcean     = np.where (o2aFrac[:] < (zone-epsfrac), True, False)
166atmOceanFrac = np.where (o2aFrac[:] > epsfrac       , True, False)
167
168NNatm = 1+2*atmCoastWidth
169atmLandFiltered = ndimage.uniform_filter(atmLand.astype(float), size=NNatm)
170atmCoast = np.where (atmLandFiltered<(1.0-0.5/(NNatm**2)),True,False) & atmLandFrac
171atmCoast = nemo.lbc_mask (atmCoast, 1, 'T')
172
173print ('Number of points in atmLand  : ' + str(atmLand.sum()) )
174print ('Number of points in atmOcean : ' + str(atmOcean.sum()) )
175print ('Number of points in atmCoast : ' + str(atmCoast.sum()) )
176
177# Arrays with coastal points only
178atmCoast_grid_center_lon = atm_grid_center_lon[atmCoast]
179atmCoast_grid_center_lat = atm_grid_center_lat[atmCoast]
180atmCoast_grid_area       = atm_grid_area      [atmCoast]
181atmCoast_grid_imask      = atm_grid_imask     [atmCoast]
182atmCoast_grid_pmask      = atm_grid_pmask     [atmCoast]
183atmCoast_address         = atm_address        [atmCoast]
184
185remap_matrix = np.empty ( shape=(0), dtype=np.float64 )
186atm_address  = np.empty ( shape=(0), dtype=np.int32   )
187oce_address  = np.empty ( shape=(0), dtype=np.int32   )
188
189## Loop on atmosphere coastal points
190for ja in np.arange(len(atmCoast_grid_pmask)) :
191    z_dist = geodist ( atmCoast_grid_center_lon[ja], atmCoast_grid_center_lat[ja], oceCoast_grid_center_lon, oceCoast_grid_center_lat)
192    z_mask = np.where ( z_dist*ra < searchRadius, True, False)
193    num_links = z_mask.sum()
194    if num_links == 0 : continue
195    z_area = oceCoast_grid_area[z_mask].sum()
196    poids = 1.0 / z_area
197    #print ( num_links, z_mask.sum(), z_area )
198    #
199    matrix_local     = np.ones ((num_links),dtype=np.float64) * poids
200    # address on source grid : all links points to the same LMDZ point.
201    atm_address_local = np.ones(num_links, dtype=np.int32 ) * atmCoast_address[ja]
202    # address on destination grid
203    oce_address_local = oceCoast_address[z_mask]
204    # Append to global tabs
205    remap_matrix = np.append ( remap_matrix, matrix_local      )
206    atm_address  = np.append ( atm_address , atm_address_local )
207    oce_address  = np.append ( oce_address , oce_address_local )
208
209print ('End of loop')
210
211num_links = remap_matrix.shape[0]
212
213### Output file
214runoff = myargs.output
215f_runoff = netCDF4.Dataset ( runoff, 'w', format=FmtNetcdf )
216print ('Output file: ' + runoff )
217
218f_runoff.Conventions     = "CF-1.6"
219f_runoff.source          = "IPSL Earth system model"
220f_runoff.group           = "ICMC IPSL Climate Modelling Center"
221f_runoff.Institution     = "IPSL https.//www.ipsl.fr"
222f_runoff.Ocean           = oce_Name + " https://www.nemo-ocean.eu"
223f_runoff.Atmosphere      = atm_Name + " http://lmdz.lmd.jussieu.fr"
224f_runoff.associatedFiles = grids + " " + areas + " " + masks
225f_runoff.directory       = os.getcwd ()
226f_runoff.description     = "Generated with cotes_etal.py"
227f_runoff.title           = runoff
228f_runoff.Program         = "Generated by " + sys.argv[0] + " with flags " + str(sys.argv[1:])
229f_runoff.atmCoastWidth   = str(atmCoastWidth) + " grid points"
230f_runoff.oceCoastWidth   = str(oceCoastWidth) + " grid points"
231f_runoff.searchRadius    = str(searchRadius/1000.) + " km"
232f_runoff.gridsFile       = grids
233f_runoff.areasFile       = areas
234f_runoff.masksFile       = masks
235f_runoff.o2aFile         = o2a
236f_runoff.timeStamp       = time.asctime()
237f_runoff.uuid            = areaFile.uuid
238f_runoff.HOSTNAME        = platform.node()
239#f_runoff.LOGNAME         = os.getlogin()
240f_runoff.Python          = "Python version " +  platform.python_version()
241f_runoff.OS              = platform.system()
242f_runoff.release         = platform.release()
243f_runoff.hardware        = platform.machine()
244f_runoff.conventions     = "SCRIP"
245f_runoff.source_grid     = "curvilinear"
246f_runoff.dest_grid       = "curvilinear"
247f_runoff.Model           = "IPSL CM6"
248f_runoff.SVN_Author      = "$Author$"
249f_runoff.SVN_Date        = "$Date$"
250f_runoff.SVN_Revision    = "$Revision$"
251f_runoff.SVN_Id          = "$Id$"
252f_runoff.SVN_HeadURL     = "$HeadURL$"
253
254d_num_links        = f_runoff.createDimension ('num_links'       , num_links )
255d_num_wgts         = f_runoff.createDimension ('num_wgts'        ,         1 )
256
257d_atm_grid_size    = f_runoff.createDimension ('src_grid_size'   , atm_grid_size )
258d_atm_grid_corners = f_runoff.createDimension ('src_grid_corners', atm_grid_corner_lon.shape[0]  )
259d_atm_grid_rank    = f_runoff.createDimension ('src_grid_rank'   ,        2  )
260
261d_oce_grid_size    = f_runoff.createDimension ('dst_grid_size'   , oce_grid_size )
262d_oce_grid_corners = f_runoff.createDimension ('dst_grid_corners', oce_grid_corner_lon.shape[0] )
263d_oce_grid_rank    = f_runoff.createDimension ('dst_grid_rank'   ,        2  )
264
265v_remap_matrix = f_runoff.createVariable ( 'remap_matrix', 'f8', ('num_links', 'num_wgts') )
266
267v_atm_address  = f_runoff.createVariable ( 'src_address' , 'i4', ('num_links',) )
268v_oce_address  = f_runoff.createVariable ( 'dst_address' , 'i4', ('num_links',) )
269
270v_remap_matrix[:] = remap_matrix
271v_atm_address [:] = atm_address + 1 # OASIS uses Fortran style indexing
272v_oce_address [:] = oce_address + 1
273
274v_atm_grid_dims       = f_runoff.createVariable ( 'src_grid_dims'      , 'i4', ('src_grid_rank',) )
275v_atm_grid_center_lon = f_runoff.createVariable ( 'src_grid_center_lon', 'i4', ('src_grid_size',) )
276v_atm_grid_center_lat = f_runoff.createVariable ( 'src_grid_center_lat', 'i4', ('src_grid_size',) )
277v_atm_grid_center_lon.units='degrees_east'  ; v_atm_grid_center_lon.long_name='Longitude' ; v_atm_grid_center_lon.long_name='longitude' ; v_atm_grid_center_lon.bounds="src_grid_corner_lon"
278v_atm_grid_center_lat.units='degrees_north' ; v_atm_grid_center_lat.long_name='Latitude'  ; v_atm_grid_center_lat.long_name='latitude ' ; v_atm_grid_center_lat.bounds="src_grid_corner_lat"
279v_atm_grid_corner_lon = f_runoff.createVariable ( 'src_grid_corner_lon', 'f8', ('src_grid_size', 'src_grid_corners')  )
280v_atm_grid_corner_lat = f_runoff.createVariable ( 'src_grid_corner_lat', 'f8', ('src_grid_size', 'src_grid_corners')  )
281v_atm_grid_corner_lon.units="degrees_east"
282v_atm_grid_corner_lat.units="degrees_north"
283v_atm_grid_area       = f_runoff.createVariable ( 'src_grid_area'      , 'f8', ('src_grid_size',)  )
284v_atm_grid_area.long_name="Grid area" ; v_atm_grid_area.standard_name="cell_area" ; v_atm_grid_area.units="m2"
285v_atm_grid_imask      = f_runoff.createVariable ( 'src_grid_imask'     , 'i4', ('src_grid_size',)  )
286v_atm_grid_imask.long_name="Land-sea mask" ; v_atm_grid_imask.units="Land:1, Ocean:0"
287v_atm_grid_pmask      = f_runoff.createVariable ( 'src_grid_pmask'     , 'i4', ('src_grid_size',)  )
288v_atm_grid_pmask.long_name="Land-sea mask (periodicity removed)" ; v_atm_grid_pmask.units="Land:1, Ocean:0"
289
290v_atm_grid_dims      [:] = atm_grid_dims
291v_atm_grid_center_lon[:] = atm_grid_center_lon[:].ravel()
292v_atm_grid_center_lat[:] = atm_grid_center_lat[:].ravel()
293v_atm_grid_corner_lon[:] = atm_grid_corner_lon.reshape( (atm_jpi*atm_jpj, d_atm_grid_corners.__len__()) )
294v_atm_grid_corner_lat[:] = atm_grid_corner_lat.reshape( (atm_jpi*atm_jpj, d_atm_grid_corners.__len__()) )
295v_atm_grid_area      [:] = atm_grid_area[:].ravel()
296v_atm_grid_imask     [:] = atm_grid_imask[:].ravel()
297v_atm_grid_pmask     [:] = atm_grid_pmask[:].ravel()
298
299# --
300
301v_oce_grid_dims       = f_runoff.createVariable ( 'dst_grid_dims'      , 'i4', ('dst_grid_rank',) )
302v_oce_grid_center_lon = f_runoff.createVariable ( 'dst_grid_center_lon', 'i4', ('dst_grid_size',) )
303v_oce_grid_center_lat = f_runoff.createVariable ( 'dst_grid_center_lat', 'i4', ('dst_grid_size',) )
304v_oce_grid_center_lon.units='degrees_east'  ; v_oce_grid_center_lon.long_name='Longitude' ; v_oce_grid_center_lon.long_name='longitude' ; v_oce_grid_center_lon.bounds="dst_grid_corner_lon"
305v_oce_grid_center_lat.units='degrees_north' ; v_oce_grid_center_lat.long_name='Latitude'  ; v_oce_grid_center_lat.long_name='latitude'  ; v_oce_grid_center_lat.bounds="dst_grid_corner_lat"
306v_oce_grid_corner_lon = f_runoff.createVariable ( 'dst_grid_corner_lon', 'f8', ('dst_grid_size', 'dst_grid_corners')  )
307v_oce_grid_corner_lat = f_runoff.createVariable ( 'dst_grid_corner_lat', 'f8', ('dst_grid_size', 'dst_grid_corners')  )
308v_oce_grid_corner_lon.units="degrees_east"
309v_oce_grid_corner_lat.units="degrees_north"
310v_oce_grid_area       = f_runoff.createVariable ( 'dst_grid_area'  , 'f8', ('dst_grid_size',) )
311v_oce_grid_area.long_name="Grid area" ; v_oce_grid_area.standard_name="cell_area" ; v_oce_grid_area.units="m2"
312v_oce_grid_imask      = f_runoff.createVariable ( 'dst_grid_imask'     , 'i4', ('dst_grid_size',)  )
313v_oce_grid_imask.long_name="Land-sea mask" ; v_oce_grid_imask.units="Land:1, Ocean:0"
314v_oce_grid_pmask      = f_runoff.createVariable ( 'dst_grid_pmask'     , 'i4', ('dst_grid_size',)  )
315v_oce_grid_pmask.long_name="Land-sea mask (periodicity removed)" ; v_oce_grid_pmask.units="Land:1, Ocean:0"
316
317v_oce_grid_dims      [:] = oce_grid_dims
318v_oce_grid_center_lon[:] = oce_grid_center_lon[:].ravel()
319v_oce_grid_center_lat[:] = oce_grid_center_lat[:].ravel()
320v_oce_grid_corner_lon[:] = oce_grid_corner_lon.reshape( (oce_jpi*oce_jpj, d_oce_grid_corners.__len__()) )
321v_oce_grid_corner_lat[:] = oce_grid_corner_lon.reshape( (oce_jpi*oce_jpj, d_oce_grid_corners.__len__()) )
322v_oce_grid_area      [:] = oce_grid_area[:].ravel()
323v_oce_grid_imask     [:] = oce_grid_imask[:].ravel()
324v_oce_grid_pmask     [:] = oce_grid_pmask[:].ravel()
325
326v_atm_lon_addressed   = f_runoff.createVariable ( 'src_lon_addressed'  , 'f8', ('num_links',) )
327v_atm_lat_addressed   = f_runoff.createVariable ( 'src_lat_addressed'  , 'f8', ('num_links',) )
328v_atm_area_addressed  = f_runoff.createVariable ( 'src_area_addressed' , 'f8', ('num_links',) )
329v_atm_imask_addressed = f_runoff.createVariable ( 'src_imask_addressed', 'i4', ('num_links',) )
330v_atm_pmask_addressed = f_runoff.createVariable ( 'src_pmask_addressed', 'i4', ('num_links',) )
331
332v_oce_lon_addressed   = f_runoff.createVariable ( 'dst_lon_addressed'  , 'f8', ('num_links',) )
333v_oce_lat_addressed   = f_runoff.createVariable ( 'dst_lat_addressed'  , 'f8', ('num_links',) )
334v_oce_area_addressed  = f_runoff.createVariable ( 'dst_area_addressed' , 'f8', ('num_links',) )
335v_oce_imask_addressed = f_runoff.createVariable ( 'dst_imask_addressed', 'i4', ('num_links',) )
336v_oce_pmask_addressed = f_runoff.createVariable ( 'dst_pmask_addressed', 'i4', ('num_links',) )
337
338v_atm_lon_addressed.long_name="Longitude" ; v_atm_lon_addressed.standard_name="longitude" ; v_atm_lon_addressed.units="degrees_east"
339v_atm_lat_addressed.long_name="Latitude"  ; v_atm_lat_addressed.standard_name="latitude"  ; v_atm_lat_addressed.units="degrees_north"
340v_atm_lon_addressed  [:] = atm_grid_center_lon.ravel()[atm_address].ravel()
341v_atm_lat_addressed  [:] = atm_grid_center_lat.ravel()[atm_address].ravel()
342v_atm_area_addressed [:] = atm_grid_area.ravel()[atm_address].ravel()
343v_atm_imask_addressed[:] = 1-atm_grid_imask.ravel()[atm_address].ravel()
344v_atm_pmask_addressed[:] = 1-atm_grid_pmask.ravel()[atm_address].ravel()
345
346v_oce_lon_addressed.long_name="Longitude" ; v_oce_lon_addressed.standard_name="longitude" ; v_oce_lon_addressed.units="degrees_east"
347v_oce_lat_addressed.long_name="Latitude"  ; v_oce_lat_addressed.standard_name="latitude"  ; v_oce_lat_addressed.units="degrees_north"
348v_oce_lon_addressed  [:] = oce_grid_center_lon.ravel()[oce_address].ravel()
349v_oce_lat_addressed  [:] = oce_grid_center_lat.ravel()[oce_address].ravel()
350v_oce_area_addressed [:] = oce_grid_area.ravel()[oce_address].ravel()
351v_oce_imask_addressed[:] = 1-oce_grid_imask.ravel()[oce_address].ravel()
352v_oce_pmask_addressed[:] = 1-oce_grid_pmask.ravel()[oce_address].ravel()
353
354v_atmLand         = f_runoff.createVariable ( 'atmLand'        , 'i4', ('src_grid_size',) )
355v_atmLandFiltered = f_runoff.createVariable ( 'atmLandFiltered', 'f4', ('src_grid_size',) )
356v_atmLandFrac     = f_runoff.createVariable ( 'atmLandFrac'    , 'i4', ('src_grid_size',) )
357v_atmFrac         = f_runoff.createVariable ( 'atmFrac'        , 'i4', ('src_grid_size',) )
358v_atmOcean        = f_runoff.createVariable ( 'atmOcean'       , 'i4', ('src_grid_size',) )
359v_atmOceanFrac    = f_runoff.createVariable ( 'atmOceanFrac'   , 'i4', ('src_grid_size',) )
360v_atmCoast        = f_runoff.createVariable ( 'atmCoast'       , 'i4', ('src_grid_size',) ) 
361
362v_atmLand[:]         = atmLand.ravel()
363v_atmLandFrac[:]     = atmLandFrac.ravel()
364v_atmLandFiltered[:] = atmLandFiltered.ravel()
365v_atmFrac[:]         = atmFrac.ravel()
366v_atmOcean[:]        = atmOcean.ravel()
367v_atmOceanFrac[:]    = atmOceanFrac.ravel()
368v_atmCoast[:]        = atmCoast.ravel()
369
370v_oceLand          = f_runoff.createVariable ( 'oceLand'         , 'i4', ('dst_grid_size',) )
371v_oceOcean         = f_runoff.createVariable ( 'oceOcean'        , 'i4', ('dst_grid_size',) )
372v_oceOceanFiltered = f_runoff.createVariable ( 'oceOceanFiltered', 'f4', ('dst_grid_size',) )
373v_oceCoast         = f_runoff.createVariable ( 'oceCoast'        , 'i4', ('dst_grid_size',) )
374
375v_oceLand[:]      = oceLand.ravel()
376v_oceOcean[:]     = oceOcean.ravel()
377v_oceOceanFiltered[:]     = oceOceanFiltered.ravel()
378v_oceCoast[:]     = oceCoast.ravel()
379
380f_runoff.sync ()
381
382##
383f_runoff.close()
384
385print ('The end')
386
387## ======================================================================================
Note: See TracBrowser for help on using the repository browser.