-
Notifications
You must be signed in to change notification settings - Fork 0
/
02_ERA5land_yearly_files.py
557 lines (463 loc) · 22.8 KB
/
02_ERA5land_yearly_files.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 27 17:29:27 2021
@author: tilloal
"""
from nco import Nco
nco = Nco()
import re
import xarray as xr
import numpy as np
from netCDF4 import Dataset
import time
import pandas as pd
from xarray import concat
# Import the os module
import os
#%%
## Script 2/4
# script that creates yearly files of daily ERA5* variables and from aggregated hourly values
# and creates yealry files from monthly files in the specified years.
# Requires:
# 1) monthly files of hourly data for the specified variables in the specified years
# (Outputs from "01_ERA5land_downloader.py")
# Output:
# 1) separate netCDF file for chosen daily variable for each year
#%%
# Print the current working directory
print("Current working directory: {0}".format(os.getcwd()))
#%%
# key text file containing (1) proxy key, (2) CDS API key, (3) working directory of the data
keys=[]
with open('Keys.txt') as f:
for line in f:
keys.append(line)
# Change the current working directory
os.chdir(keys[2])
#%%
# Print the current working directory
print("Current working directory: {0}".format(os.getcwd()))
# Parameters for the generation of new netcdf files
__OUTPUT_FILE_EXT = '.nc'
__NETCDF_DATASET_FORMAT = 'NETCDF4_CLASSIC'
__NETCDF_CONVENTIONS = 'CF-1.6'
__NETCDF_SOURCE_SOFTWARE = 'Python netCDF4'
__NETCDF_VAR_TIME_DIMENSION = None
__NETCDF_VAR_TIME_CALENDAR_TYPE = 'proleptic_gregorian'
__NETCDF_VAR_DATA_TYPE = 'f8'
__NETCDF_VALUE_DATA_TYPE = 'f4'
__NETCDF_COORDINATES_DATA_TYPE = 'i4'
__KEY_STANDARD_NAME = 'value_standard_name'
__KEY_LONG_NAME = 'value_long_name'
__KEY_UNIT = 'value_unit'
__KEY_OFFSET = 0
__KEY_SCALE_FACTOR = 1
__KEY_VMIN = -400
__KEY_VMAX = 400
# compressions factors for variables tp, ws, rg, rn, td
factorz=pd.read_csv('compression_factors.csv')
#%%
# function to estimate optimal add_offset and scale_factor for other variables
def compute_scale_and_offset(min, max, n):
# stretch/compress data to the available packed range
scale_factor = (max - min) / (2 ** n - 1)
# translate the range to be symmetric about zero
add_offset = min + 2 ** (n - 1) * scale_factor
return (scale_factor, add_offset)
facto=False
if facto==True:
__meteo_vars_config = {
'tn' : {__KEY_UNIT : 'celcius', __KEY_STANDARD_NAME : 'tn', __KEY_LONG_NAME : 'min_temperature',
__KEY_OFFSET : 0, __KEY_SCALE_FACTOR : 0.1, __KEY_VMIN : -700, __KEY_VMAX : 700},
'tp' : {__KEY_UNIT : 'mm', __KEY_STANDARD_NAME : 'tp', __KEY_LONG_NAME : 'total_precipitation',
__KEY_OFFSET : factorz['add_offset'].values[5], __KEY_SCALE_FACTOR : factorz['scale_factor'].values[5], __KEY_VMIN : -1, __KEY_VMAX : 7000},
'ta' : {__KEY_UNIT : 'celcius', __KEY_STANDARD_NAME : 'ta', __KEY_LONG_NAME : 'mean_temperature',
__KEY_OFFSET : factorz['add_offset'].values[1], __KEY_SCALE_FACTOR : factorz['scale_factor'].values[1], __KEY_VMIN : -700, __KEY_VMAX : 700},
'td' : {__KEY_UNIT : 'celcius', __KEY_STANDARD_NAME : 'td', __KEY_LONG_NAME : 'mean_dewpoint_temperature',
__KEY_OFFSET : factorz['add_offset'].values[4], __KEY_SCALE_FACTOR : factorz['scale_factor'].values[4], __KEY_VMIN : -700, __KEY_VMAX : 700},
'tx' : {__KEY_UNIT : 'celcius', __KEY_STANDARD_NAME : 'tx', __KEY_LONG_NAME : 'max_temperature',
__KEY_OFFSET : 0, __KEY_SCALE_FACTOR : 0.1, __KEY_VMIN : -400, __KEY_VMAX : 400},
'ws' : {__KEY_UNIT : 'm/s', __KEY_STANDARD_NAME : 'ws', __KEY_LONG_NAME : 'avg_wind_speed',
__KEY_OFFSET : factorz['add_offset'].values[0], __KEY_SCALE_FACTOR : factorz['scale_factor'].values[0], __KEY_VMIN : -400, __KEY_VMAX : 400},
'rg' : {__KEY_UNIT : 'J/m2/d', __KEY_STANDARD_NAME : 'ssr', __KEY_LONG_NAME : 'surface_net_solar_radiation',
__KEY_OFFSET : factorz['add_offset'].values[2], __KEY_SCALE_FACTOR : factorz['scale_factor'].values[2]},
'rgd' : {__KEY_UNIT : 'J/m2/d', __KEY_STANDARD_NAME : 'ssrd', __KEY_LONG_NAME : 'surface_downward_solar_radiation',
__KEY_OFFSET :0, __KEY_SCALE_FACTOR : 1000},
'rn' : {__KEY_UNIT : 'J/m2/d', __KEY_STANDARD_NAME : 'str', __KEY_LONG_NAME : 'surface_net_thermal_radiation',
__KEY_OFFSET : factorz['add_offset'].values[3], __KEY_SCALE_FACTOR : factorz['scale_factor'].values[3]},
}
if facto==False:
__meteo_vars_config = {
'tn' : {__KEY_UNIT : 'celcius', __KEY_STANDARD_NAME : 'tn', __KEY_LONG_NAME : 'min_temperature',
__KEY_OFFSET : 0.0, __KEY_SCALE_FACTOR : 0.1, __KEY_VMIN : -700, __KEY_VMAX : 700},
'tp' : {__KEY_UNIT : 'mm', __KEY_STANDARD_NAME : 'tp', __KEY_LONG_NAME : 'total_precipitation',
__KEY_OFFSET : 0.0, __KEY_SCALE_FACTOR : 0.1, __KEY_VMIN : -1, __KEY_VMAX : 7000},
'evavt' : {__KEY_UNIT : 'mm', __KEY_STANDARD_NAME : 'evavt', __KEY_LONG_NAME : 'evaporation_from_vegetation_transpiration',
__KEY_OFFSET : 0.0, __KEY_SCALE_FACTOR : 0.1, __KEY_VMIN : -1, __KEY_VMAX : 7000},
'ta' : {__KEY_UNIT : 'celcius', __KEY_STANDARD_NAME : 'ta', __KEY_LONG_NAME : 'mean_temperature',
__KEY_OFFSET : 0.0, __KEY_SCALE_FACTOR : 0.1, __KEY_VMIN : -700, __KEY_VMAX : 700},
'td' : {__KEY_UNIT : 'celcius', __KEY_STANDARD_NAME : 'td', __KEY_LONG_NAME : 'mean_dewpoint_temperature',
__KEY_OFFSET : 0.0, __KEY_SCALE_FACTOR : 0.1, __KEY_VMIN : -700, __KEY_VMAX : 700},
'tx' : {__KEY_UNIT : 'celcius', __KEY_STANDARD_NAME : 'tx', __KEY_LONG_NAME : 'max_temperature',
__KEY_OFFSET : 0.0, __KEY_SCALE_FACTOR : 0.1, __KEY_VMIN : -400, __KEY_VMAX : 400},
'ws' : {__KEY_UNIT : 'm/s', __KEY_STANDARD_NAME : 'ws', __KEY_LONG_NAME : 'avg_wind_speed',
__KEY_OFFSET : 0.0, __KEY_SCALE_FACTOR : 0.1, __KEY_VMIN : 0, __KEY_VMAX : 45},
'u10' : {__KEY_UNIT : 'm/s', __KEY_STANDARD_NAME : 'u10', __KEY_LONG_NAME : 'avg_u_component_wind',
__KEY_OFFSET : 0.0, __KEY_SCALE_FACTOR : 0.1, __KEY_VMIN : 0, __KEY_VMAX : 45},
'v10' : {__KEY_UNIT : 'm/s', __KEY_STANDARD_NAME : 'ws', __KEY_LONG_NAME : 'avg_v_component_wind',
__KEY_OFFSET : 0.0, __KEY_SCALE_FACTOR : 0.1, __KEY_VMIN : 0, __KEY_VMAX : 45},
'rg' : {__KEY_UNIT : 'J/m2/d', __KEY_STANDARD_NAME : 'ssr', __KEY_LONG_NAME : 'surface_net_solar_radiation',
__KEY_OFFSET : 0.0, __KEY_SCALE_FACTOR : 10000.0},
'rgd' : {__KEY_UNIT : 'J/m2/d', __KEY_STANDARD_NAME : 'ssrd', __KEY_LONG_NAME : 'surface_downward_solar_radiation',
__KEY_OFFSET :0.0, __KEY_SCALE_FACTOR : 10000.0},
'rn' : {__KEY_UNIT : 'J/m2/d', __KEY_STANDARD_NAME : 'str', __KEY_LONG_NAME : 'surface_net_thermal_radiation',
__KEY_OFFSET : 0.0, __KEY_SCALE_FACTOR : 10000.0},
}
vars_list = ' | '.join(__meteo_vars_config.keys())
#%
#%%
# function to compute mean wind speed from u and v components of wind
def wind_uv_to_spd(U,V):
"""
Calculates the wind speed from the u and v wind components
Inputs:
U = west/east direction (wind from the west is positive, from the east is negative)
V = south/noth direction (wind from the south is positive, from the north is negative)
"""
WSPD=np.sqrt(U**2+V**2)
return WSPD
# function to write a new netcdf file
def writenetcdf(yr, vr, dt, scale_factor, add_offset):
rfile = dt.copy()
tziz=(rfile['time'])
d1=(tziz[0])
d2=np.datetime_as_string(d1, unit='D')
d3=" 00:00:00"
d4=d2+d3
tunits= 'days since ' + d2
d1=os.getcwd() + '\\'
d2= vr + '\\0.1_deg\e5ldxc_' + vr + '_'+ yr + '.nc'
namenc=d1+d2
nf2=Dataset(namenc,mode='w',format='NETCDF4_CLASSIC')
nf2.history = 'Created Nov 2021' #####
nf2.Conventions = 'CF-1.6'
nf2.Source_Software = 'Python netCDF4'
nf2.reference = 'A global daily high-resolution gridded meteorological data set for 1979-2019' #####
nf2.title = 'Lisflood meteo maps 1981 for EUROPE setting Nov. 2021'
nf2.keywords = 'Lisflood, Global'
nf2.source = 'ERA5-land'
nf2.institution = 'European Commission - Economics of climate change Unit (JRC.C.6) : https://ec.europa.eu/jrc/en/research-topic/climate-change'
nf2.comment = 'The timestamp marks the end of the aggregation interval for a given map.'
#Dimension
nf2.createDimension('lon', 756)
nf2.createDimension('lat', 501)
nf2.createDimension('time', None)
#Variables
longitude = nf2.createVariable('lon','f4',('lon',), complevel=4, zlib=True) ###('lon','f8',('lon',))
longitude.standard_name= 'Longitude'
longitude.long_name= 'Longitude'
longitude.units = 'degrees_east'
latitude = nf2.createVariable('lat','f4',('lat',), complevel=4, zlib=True) ###('lon','f8',('lon',))
latitude.standard_name= 'Latitude'
latitude.long_name= 'Latitude'
latitude.units = 'degrees_north'
time = nf2.createVariable('time', 'i4', ('time',), complevel=4, zlib=True)
time.standard_name = 'time'
time.units = tunits
time.frequency = '1'
time.calendar = 'proleptic_gregorian'
proj = nf2.createVariable('wsg_1984', 'i4')
proj.grid_mapping_name = 'latitude_longitude'
#proj.false_easting= ''
#proj.false_northing= ''
#proj.longitude_of_projection_origin= ''
#proj.latitude_of_projection_origin= ''
proj.semi_major_axis= '6378137.0'
proj.inverse_flattening='298.257223563'
proj.proj4_params='+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'
proj.EPSG_code='EPSG:4326'
#proj.spatial_ref='GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4326"]]'
if vr in ['ssr','str']:
E5landata = nf2.createVariable(vr, 'i2',('time','lat','lon',), zlib=True, complevel=4, fill_value=-9999)
else:
E5landata = nf2.createVariable(vr, 'i2',('time','lat','lon',), zlib=True, complevel=4, fill_value=-9999)
E5landata.standard_name = __meteo_vars_config[vr][__KEY_STANDARD_NAME]
E5landata.missing_value=-9999
E5landata.long_name = __meteo_vars_config[vr][__KEY_LONG_NAME]
E5landata.units = __meteo_vars_config[vr][__KEY_UNIT]
#E5landata.valid_min=(int(np.min(rfile))-add_offset)/scale_factor
#E5landata.valid_max=(int(np.max(rfile))-add_offset)/scale_factor-100
#E5landata.valid_min=__meteo_vars_config[vr][__KEY_VMIN]
#E5landata.valid_max=__meteo_vars_config[vr][__KEY_VMAX]
E5landata.scale_factor=scale_factor
E5landata.add_offset=add_offset
E5landata.set_auto_maskandscale(False)
print(E5landata.units)
E5landata.grid_mapping='wgs_1984'
E5landata.esri_pe_string='GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4326"]]'
#kiko=np.stack(rfile['latitude'])
#koki=np.stack(rfile['longitude'])
kaka=len(rfile['time'])
latitude[:]=np.arange(72.25, 22.15, -0.1) ##-89.999 999 999 999 9716 -89.999 999 999 999 9858
longitude[:]=np.arange(-25.25, 50.35, 0.1)
time[:]=np.arange(kaka)
#wala=np.isnan(results)
#print(wala)
#wali=np.asmatrix(results,dtype='uint8')
__VALUE_NAN=-9999
resulti=rfile.fillna(__VALUE_NAN)
#lona=round(__VALUE_NAN * scale_factor +add_offset,1)
#resulti[np.isnan(resulti)] = __VALUE_NAN * scale_factor +add_offset
#if vr in ['ssr','str']:
#resulti=resulti.astype('f4')
#else:
#resulti=resulti.astype('f4')
for t in range(kaka):
E5landata[t,:,:]=resulti[t,:,:]
####print(E5landata)
nf2.close()
resulti=[]
# Uncomment years as required
years = [
#'1981',
#'1982', '1983', '1984',
#'1985', '1986', '1987','1988', '1989',
#'1990',
#'1991', '1992', '1993',
#'1994', '1995', '1996',
#'1997', '1998',
#'1999',
#'2000', '2001', '2002',
#'2003',
#'2004', '2005','2006',
#'2007', '2008','2009',
#'2010', '2011',
'2012',
#'2013', '2014','2015', '2016', '2017','2018', '2019', '2020',
]
months = [ "01",
"02", "03", "04", "05", "06",
"07", "08", "09", "10", "11", "12"
]
# select your variable(s); name must be a valid ERA5 CDS API name
varconf=['u10', 'v10','t2m','str','ssr','d2m','ssrd']
vc=varconf
#%%
# define names of new variables
tvar = ['ws', 'ta','rg','rn','td','tp','rgd','u10','v10']
var = tvar
#%%
# parameter linked to the way data have been downloaded
# fi=1 // all duration
# fi=2 // 1991 - 2002
fi2=['1991', '1992', '1993',
'1994', '1995', '1996',
'1997', '1998',
'1999',
'2000', '2001', '2002']
# fi=3 // 1981-1990 & 2003-2020
fi=1
#%%
for yr in years:
for mo in months:
#%%
if fi==1:
hourly_v = xr.open_dataset(os.getcwd() + '/hourly/e5l_'+ yr + '_' + mo + '.nc')
hourly_v2 = xr.open_dataset(os.getcwd() + '/hourly/e5l_ssrd_'+ yr + '_' + mo + '.nc')
#hourly_v = xr.open_dataset(os.getcwd() + '/hourly/e5l_evavt_'+ yr + '_' + mo + '.nc')
if yr in fi2:
hourly_v3 = xr.open_dataset(os.getcwd() + '/hourly/e5l_tp-2d_'+ yr + '_' + mo + '.nc')
if fi==3:
hourly_v = xr.open_dataset(os.getcwd() + '/hourly/e5l_tp_'+ yr + '_' + mo + '.nc')
vax=list(hourly_v.keys())
#vc=vax
print("the variables in this file are " + ' | '.join(vax))
print('month ' + mo + " year " + yr)
vax=vc
tan=len(hourly_v['time'])
koudur=range(0,tan,24)
start = time.time()
if 'u10' in vc and 'v10' in vc:
v10= hourly_v['v10']
u10 = hourly_v['u10']
#wind= wind_uv_to_spd(u10,v10)
u10=u10.rename('u10')
daily_u = u10.resample(time='D').mean('time')
v10=v10.rename('v10')
daily_v = v10.resample(time='D').mean('time')
if mo=="01":
du=daily_u
dv=daily_v
else:
du = concat([du,daily_u],dim='time')
dv = concat([dv,daily_v],dim='time')
# daily accumulation of precipitation
if 'tp' in vc:
tp= hourly_v['tp']
#convertion to mm
tp=tp*1000
daily_pr=tp.resample(time='D').max('time')
dptest= daily_pr
bite=[np.max(dptest),np.min(dptest)]
print(bite)
#dptest.plot.surface(yincrease=True)
daily_pr=daily_pr.rename('tp')
if mo=="01":
dtp=daily_pr
else:
dtp = concat([dtp,daily_pr],dim='time')
# precipitation: calculate sum with frequency of 24h and multiply by 1000
# precipitation value is for the day before
# daily mean of tempearature
if 't2m'in vc:
t2m=hourly_v['t2m']
#convert Kelvin to degrees C
t2mb=t2m-273.15
daily_t2mb = t2mb.resample(time='D').mean('time')
daily_t2m = t2m.resample(time='D').mean('time')
daily_t2m=daily_t2m-273.15
mamene=t2mb[0:700,410,200]
#mamene.plot()
#daily_t2m[:,410,200].plot()
#daily_t2mb[:,410,200].plot()
daily_t2m=daily_t2m.rename('ta')
if mo=="01":
dta=daily_t2m
else:
dta = concat([dta,daily_t2m],dim='time')
# daily means of surface net thermal radiation and surface net solar radiation
if 'str'in vc:
sstr=hourly_v['str']
daily_rn = sstr[koudur,:,:]
daily_rn2 = sstr.resample(time='D').min('time')
#daily_rn2[:,400,200].plot()
#dd=daily_rn[:,300,200]
#dd2=daily_rn2[:,300,200]
#dd.plot()
daily_rn=daily_rn.rename('rn')
if mo=="01":
drn=daily_rn
else:
drn = concat([drn,daily_rn],dim='time')
if 'ssr'in vc:
ssr=hourly_v['ssr']
mamene=ssr[range(260,300),300,200]
mamene.plot()
daily_rg = ssr[koudur,:,:]
#daily_rg = ssr.resample(time='D').sum('time',min_count=4)
daily_rg= daily_rg.rename('rg')
if mo=="01":
drg=daily_rg
else:
drg = concat([drg,daily_rg],dim='time')
if 'ssrd'in vc:
ssrd=hourly_v2['ssrd']
mamene=ssrd[range(0,300),300,200]
mamene.plot()
daily_rgd = ssrd[koudur,:,:]
daily_rgd[:,300,200].plot()
#daily_rg = ssr.resample(time='D').sum('time',min_count=4)
daily_rgd= daily_rgd.rename('rgd')
if mo=="01":
drgd=daily_rgd
else:
drgd = concat([drgd,daily_rgd],dim='time')
if 'evavt'in vc:
et0=hourly_v['evavt']
#convertion to mm
et0=et0*1000
mamene=et0[range(260,300),300,200]
mamene.plot()
daily_et0 = et0[koudur,:,:]
#daily_et0[:,300,200].plot()
#daily_rg = ssr.resample(time='D').sum('time',min_count=4)
daily_et0= daily_et0.rename('et0')
if mo=="01":
det=daily_et0
else:
det = concat([det,daily_et0],dim='time')
# daily mean of dew point temperature
if 'd2m'in vc:
if yr in fi2:
d2m=hourly_v3['d2m']
else:
d2m=hourly_v['d2m']
#convert Kelvin to degrees C
d2m=d2m-273.15
daily_d2m = d2m.resample(time='D').mean('time')
daily_d2m=daily_d2m.rename({'td'})
if mo=="01":
dtd=daily_d2m
else:
dtd = concat([dtd,daily_d2m],dim='time')
#dailymax_t2m = t2m.resample(time='D').max('time')
#dailymax_t2m=dailymax_t2m.rename({'tx'})
#dailymin_t2m = t2m.resample(time='D').min('time')
#dailymin_t2m=dailymin_t2m.rename({'tn'})
end=time.time()
print(end - start)
# generate new yearly netcdf of daily values of the variables using scale factor ans add offset
if 'u10' in vax:
dt=du
vr=var[7]
scale_factor, add_offset = __meteo_vars_config[vr][__KEY_SCALE_FACTOR],__meteo_vars_config[vr][__KEY_OFFSET]
dtx=np.round((dt - add_offset) / scale_factor)
print ('Start generating netcdf file for variable: '+ vr)
print(scale_factor)
writenetcdf(yr,vr,dtx,scale_factor,add_offset)
if 'v10' in vax:
dt=dv
vr=var[8]
scale_factor, add_offset = __meteo_vars_config[vr][__KEY_SCALE_FACTOR],__meteo_vars_config[vr][__KEY_OFFSET]
dtx=np.round((dt - add_offset) / scale_factor)
print ('Start generating netcdf file for variable: '+ vr)
print(scale_factor)
writenetcdf(yr,vr,dtx,scale_factor,add_offset)
if 't2m' in vax:
dt=dta
vr=var[1]
scale_factor, add_offset = __meteo_vars_config[vr][__KEY_SCALE_FACTOR],__meteo_vars_config[vr][__KEY_OFFSET]
dtx=np.round((dt - add_offset) / scale_factor)
print ('Start generating netcdf file for variable: '+ vr)
print(scale_factor)
writenetcdf(yr,vr,dtx,scale_factor,add_offset)
if 'ssr' in vax:
dt=drg
vr=var[2]
scale_factor, add_offset = __meteo_vars_config[vr][__KEY_SCALE_FACTOR],__meteo_vars_config[vr][__KEY_OFFSET]
dtx=np.round((dt - add_offset) / scale_factor)
print ('Start generating netcdf file for variable: '+ vr)
print(scale_factor)
writenetcdf(yr,vr,dtx,scale_factor,add_offset)
if 'ssrd' in vax:
dt=drgd
vr=var[6]
scale_factor, add_offset = __meteo_vars_config[vr][__KEY_SCALE_FACTOR],__meteo_vars_config[vr][__KEY_OFFSET]
dtx=np.round((dt - add_offset) / scale_factor)
print ('Start generating netcdf file for variable: '+ vr)
print(scale_factor)
writenetcdf(yr,vr,dtx,scale_factor,add_offset)
if 'str' in vax:
dt=drn
vr=var[3]
scale_factor, add_offset = __meteo_vars_config[vr][__KEY_SCALE_FACTOR],__meteo_vars_config[vr][__KEY_OFFSET]
dtx=np.round((dt - add_offset) / scale_factor)
print ('Start generating netcdf file for variable: '+ vr)
print(scale_factor)
writenetcdf(yr,vr,dtx,scale_factor,add_offset)
if 'd2m' in vax:
dt=dtd
vr=var[4]
scale_factor, add_offset = __meteo_vars_config[vr][__KEY_SCALE_FACTOR],__meteo_vars_config[vr][__KEY_OFFSET]
dtx=np.round((dt - add_offset) / scale_factor)
print ('Start generating netcdf file for variable: '+ vr)
print(scale_factor)
writenetcdf(yr,vr,dtx,scale_factor,add_offset)
if 'tp' in vax:
dt=dtp
vr=var[5]
scale_factor, add_offset = __meteo_vars_config[vr][__KEY_SCALE_FACTOR],__meteo_vars_config[vr][__KEY_OFFSET]
dtx=np.round((dt - add_offset) / scale_factor)
print ('Start generating netcdf file for variable: '+ vr)
print(scale_factor)
writenetcdf(yr,vr,dtx,scale_factor,add_offset)