-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTData_products_L.py
51 lines (41 loc) · 1.68 KB
/
TData_products_L.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
# L
def liquid_water_content(meta, mode, nc, ver):
import TData_data as dat
import TData_common as com
import numpy as np
[ET, DT, DoY] = dat.create_time(meta)
[lat, lon] = dat.create_pos(ET, mode)
[data_1d, flag_1d, min_dat, max_dat] = dat.create_data_flag(ET)
# write common global attrib
com.global_attributes(nc, meta, ET, mode)
# write specific global attrib
nc.product_version = ver
# write common dimensions
com.dimensions(nc, ET, lat, lon)
# write specific dimensions
# write common variables
com.variables(nc, ET, DT, DoY, lat, lon, mode)
# write specific variables
v = nc.createVariable('cloud_liquid_water_content', np.float32, ('time',), fill_value=-1.00e+20)
#variable attributes
v.units = 'kg m-2'
v.long_name = 'Cloud Liquid Water Content'
v.valid_min = np.float32(min_dat)
v.valid_max = np.float32(max_dat)
v.cell_methods = 'time: mean'
v.coordinates = 'latitude longitude'
#write data
v[:] = np.float32(data_1d)
v = nc.createVariable('qc_flag', np.int8, ('time',))
#variable attribute
v.units = '1'
v.long_name = 'Data Quality Flag'
v.flag_values = '0b,1b,2b,3b,4b'
v.flag_meanings = 'not_used' + '\n'
v.flag_meanings = v.flag_meanings + 'good_data' + '\n'
v.flag_meanings = v.flag_meanings + 'suspect_data_data_not_quality_controlled:_data<0.075' + '\n'
v.flag_meanings = v.flag_meanings + 'suspect_data_data_not_quality_controlled:_data>0.925' + '\n'
v.flag_meanings = v.flag_meanings + 'bad_data_do_not_use:_data=0'
#write data
v[:] = np.int8(flag_1d)
del dat, com, np, data_1d, flag_1d