-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTData_products_T.py
94 lines (81 loc) · 3.52 KB
/
TData_products_T.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
# T
def tgm_concentration(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('mole_fraction_of_gaseous_elemental_mercury_in_air', np.float32, ('time',), fill_value=-1.00e+20)
#variable attributes
v.units = '1e-9'
v.practical_units = 'nmol mol-1'
v.standard_name = 'mole_fraction_of_gaseous_elemental_mercury_in_air'
v.long_name = 'Mole Fraction of Gaseous Elemental Mercury in air'
v.valid_min = np.float32(min_dat)
v.valid_max = np.float32(max_dat)
v.cell_methods = 'time: mean'
v.coordinates = 'latitude longitude'
v.chemical_species = 'Hg'
#write data
v[:] = np.float32(data_1d)
v = nc.createVariable('mass_fraction_of_gaseous_elemental_mercury_in_air', np.float32, ('time',), fill_value=-1.00e+20)
#variable attributes
v.units = '1e-9'
v.practical_units = 'ppt'
v.standard_name = 'mass_fraction_of_gaseous_elemental_mercury_in_air'
v.long_name = 'Mass Fraction of Gaseous Elemental Mercury in air'
v.valid_min = np.float32(min_dat)
v.valid_max = np.float32(max_dat)
v.cell_methods = 'time: mean'
v.coordinates = 'latitude longitude'
v.chemical_species = 'Hg'
#write data
v[:] = np.float32(data_1d)
v = nc.createVariable('mole_concentration_of_gaseous_elemental_mercury_in_air', np.float32, ('time',), fill_value=-1.00e+20)
#variable attributes
v.units = 'mol m-3'
v.standard_name = 'mole_concentration_of_gaseous_elemental_mercury_in_air'
v.long_name = 'Mole Concentration of Gaseous Elemental Mercury in air'
v.valid_min = np.float32(min_dat)
v.valid_max = np.float32(max_dat)
v.cell_methods = 'time: mean'
v.coordinates = 'latitude longitude'
v.chemical_species = 'Hg'
#write data
v[:] = np.float32(data_1d)
v = nc.createVariable('mass_concentration_of_gaseous_elemental_mercury_in_air', np.float32, ('time',), fill_value=-1.00e+20)
#variable attributes
v.units = 'kg m-3'
v.standard_name = 'mass_concentration_of_gaseous_elemental_mercury_in_air'
v.long_name = 'Mass Concentration of Gaseous Elemental Mercury in air'
v.valid_min = np.float32(min_dat)
v.valid_max = np.float32(max_dat)
v.cell_methods = 'time: mean'
v.coordinates = 'latitude longitude'
v.chemical_species = 'Hg'
#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