Alaea 2.4.2__tar.gz → 2.4.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {alaea-2.4.2 → alaea-2.4.4}/.DS_Store +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/Standard/__init__.py +2 -0
- alaea-2.4.4/Alaea/Standard/vars_name.py +52 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/Standard/xr_attrs.py +216 -129
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/__init__.py +8 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/baysalt/erosion_coastline.py +1 -0
- {alaea-2.4.2 → alaea-2.4.4/Alaea.egg-info}/PKG-INFO +1 -1
- {alaea-2.4.2 → alaea-2.4.4}/Alaea.egg-info/SOURCES.txt +1 -0
- {alaea-2.4.2/Alaea.egg-info → alaea-2.4.4}/PKG-INFO +1 -1
- {alaea-2.4.2 → alaea-2.4.4}/setup.py +1 -1
- {alaea-2.4.2 → alaea-2.4.4}/.gitattributes +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/.gitignore +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/Blogging.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/Pyshell/RS_File.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/Pyshell/__init__.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/S_DateTime.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/SameAsMATLAB/CoorTrans.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/SameAsMATLAB/__init__.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/SameAsMATLAB/calculatefuns.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/Standard/xr_ice.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/Standard/xr_wave.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/baysalt/Forage/__init__.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/baysalt/Forage/erosion_data/__init__.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/baysalt/__init__.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/commonCode.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/cprintfs.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/exutils/Interp/Interp_g2s.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/exutils/Interp/Interp_s2g.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/exutils/Interp/__init__.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/exutils/__init__.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/pFVCOM/__init__.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/pFVCOM/fvcom_class.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/pFVCOM/fvcom_image.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/pFVCOM/fvcom_load.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/pFVCOM/fvcom_tools.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/pFVCOM/writeFile.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/processBar.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/read_conf.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/server_info.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/tools/P_params.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/tools/Read.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/tools/__init__.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/tools/download_check.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/tools/geo_distance.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/tools/kml2shp.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea/warningTools/__init__.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea.egg-info/dependency_links.txt +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea.egg-info/requires.txt +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/Alaea.egg-info/top_level.txt +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/MANIFEST.in +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/README.md +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/run_twine.py +0 -0
- {alaea-2.4.2 → alaea-2.4.4}/setup.cfg +0 -0
|
Binary file
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
# 日期 : 2026/4/24 10:48
|
|
4
|
+
# 作者 : Christmas
|
|
5
|
+
# 邮箱 : 273519355@qq.com
|
|
6
|
+
# 项目 : Alaea
|
|
7
|
+
# 版本 : python 3
|
|
8
|
+
# 摘要 :
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
NAME_lon = ['lon', 'longitude']
|
|
15
|
+
NAME_lat = ['lat', 'latitude']
|
|
16
|
+
|
|
17
|
+
NAME_time = ['time']
|
|
18
|
+
NAME_TIME = ['TIME']
|
|
19
|
+
|
|
20
|
+
NAME_u10 = ['wind_U10', 'U10', 'u10']
|
|
21
|
+
NAME_v10 = ['wind_V10', 'V10', 'v10']
|
|
22
|
+
NAME_wpsd10max = ['WSPD10MAX']
|
|
23
|
+
|
|
24
|
+
NAME_t2 = ['temperature', 'T2', 't2']
|
|
25
|
+
|
|
26
|
+
NAME_visi = ['visibility', 'AFWA_VIS', 'VISIBILITY']
|
|
27
|
+
|
|
28
|
+
NAME_swr = ['SWR', 'Shortwave', 'SWDOWN']
|
|
29
|
+
NAME_lwr = ['LWR', 'Longwave', 'GLW']
|
|
30
|
+
NAME_swrn = ['SWRN', 'SWDOWN_NORM', 'SWNORM']
|
|
31
|
+
|
|
32
|
+
NAME_tcc = ['tcc', 'TCC', 'cloud_cover']
|
|
33
|
+
|
|
34
|
+
NAME_prec = ['precipitation', 'tp', 'TP', 'Precipitation']
|
|
35
|
+
|
|
36
|
+
NAME_slp = ['slp', 'SLP']
|
|
37
|
+
|
|
38
|
+
NAME_swh = ['swh', 'SWH', 'Significant_wave_height']
|
|
39
|
+
NAME_mwp = ['mwp', 'MWP', 'Mean_wave_period']
|
|
40
|
+
NAME_mwd = ['mwd', 'MWD', 'Mean_wave_direction']
|
|
41
|
+
NAME_mwl = ['mwl', 'MWL', 'Mean_wave_length']
|
|
42
|
+
NAME_shww = ['shww', 'SHWW', 'Significant_wave_height_of_swell']
|
|
43
|
+
NAME_shts = ['shts', 'SHTS', 'Significant_wave_height_of_sea']
|
|
44
|
+
NAME_mdww = ['mdww', 'MDWW', 'Mean_wave_direction_of_swell']
|
|
45
|
+
NAME_mdts = ['mdts', 'MDTS', 'Mean_wave_direction_of_sea']
|
|
46
|
+
NAME_mpww = ['mpww', 'MPWW', 'Mean_wave_period_of_swell']
|
|
47
|
+
NAME_mpts = ['mpts', 'MPTS', 'Mean_wave_period_of_sea']
|
|
48
|
+
NAME_pp1d = ['pp1d', 'PP1D', 'Peak_period_of_1st_wave_component']
|
|
49
|
+
NAME_hmax = ['hmax', 'HMAX', 'Max_wave_height']
|
|
50
|
+
|
|
51
|
+
NAME_aice = ['aice', 'AICE', 'sea_ice_concentration']
|
|
52
|
+
NAME_tice = ['tice', 'TICE', 'sea_ice_thickness']
|
|
@@ -9,18 +9,21 @@
|
|
|
9
9
|
"""
|
|
10
10
|
xarray.Dataset attrs
|
|
11
11
|
"""
|
|
12
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
12
13
|
from typing import Optional, Union
|
|
13
14
|
|
|
14
15
|
import numpy as np
|
|
15
16
|
import xarray as xr
|
|
16
17
|
|
|
18
|
+
from .vars_name import *
|
|
19
|
+
|
|
17
20
|
# from .. import new_filename
|
|
18
21
|
|
|
19
22
|
__all__ = ['add_coors_attrs',
|
|
20
23
|
'add_lon_attrs', 'add_lat_attrs', 'add_time_attrs', 'add_TIME_attrs',
|
|
21
24
|
'add_wind_attrs', 'add_temperature_attrs', 'add_precipitation_attrs', 'add_slp_attrs',
|
|
22
|
-
'add_wave_attrs', '
|
|
23
|
-
'
|
|
25
|
+
'add_wave_attrs', 'add_visibility_attrs', 'add_radiation_attrs', 'add_cloudCover_attrs',
|
|
26
|
+
'add_ice_attrs', 'transpose_dims',
|
|
24
27
|
'fixed_encoding', 'calc_scale_offset', 'compress_scale_offset',
|
|
25
28
|
'calc_dtype', 'calc_fillvalue',
|
|
26
29
|
]
|
|
@@ -42,10 +45,10 @@ def add_coors_attrs(
|
|
|
42
45
|
:param TIME_name: TIME维度名,默认为自动识别
|
|
43
46
|
:return: xarray.Dataset
|
|
44
47
|
"""
|
|
45
|
-
lon_name = next((x for x in
|
|
46
|
-
lat_name = next((x for x in
|
|
47
|
-
time_name = next((x for x in
|
|
48
|
-
TIME_name = next((x for x in
|
|
48
|
+
lon_name = next((x for x in NAME_lon if x in _ds.dims), None) if lon_name is None else lon_name
|
|
49
|
+
lat_name = next((x for x in NAME_lat if x in _ds.dims), None) if lat_name is None else lat_name
|
|
50
|
+
time_name = next((x for x in NAME_time if x in _ds.dims), None) if time_name is None else time_name
|
|
51
|
+
TIME_name = next((x for x in NAME_TIME if x in _ds.variables), None) if TIME_name is None else TIME_name
|
|
49
52
|
|
|
50
53
|
add_lon_attrs(_ds, lon_name)
|
|
51
54
|
add_lat_attrs(_ds, lat_name)
|
|
@@ -133,12 +136,12 @@ def add_TIME_attrs(
|
|
|
133
136
|
:return: xarray.Dataset
|
|
134
137
|
"""
|
|
135
138
|
_ds[TIME_name].attrs = {
|
|
136
|
-
'reference_time': ''.join(_ds[TIME_name].
|
|
139
|
+
'reference_time': ''.join(_ds[TIME_name].values[0].astype(str))[:10],
|
|
137
140
|
'long_name': 'UTC time',
|
|
138
141
|
'standard_name': 'UTC_time',
|
|
139
142
|
'calendar': 'gregorian',
|
|
140
|
-
'start_time': ''.join(_ds[TIME_name].
|
|
141
|
-
'end_time': ''.join(_ds[TIME_name].
|
|
143
|
+
'start_time': ''.join(_ds[TIME_name].values[0].astype(str)),
|
|
144
|
+
'end_time': ''.join(_ds[TIME_name].values[-1].astype(str))
|
|
142
145
|
}
|
|
143
146
|
_ds[TIME_name].encoding['char_dim_name'] = dim_name
|
|
144
147
|
# _ds[TIME_name].encoding['zlib'] = True
|
|
@@ -147,32 +150,37 @@ def add_TIME_attrs(
|
|
|
147
150
|
|
|
148
151
|
def add_wind_attrs(
|
|
149
152
|
_ds: xr.Dataset,
|
|
150
|
-
|
|
151
|
-
|
|
153
|
+
u10_name: Optional[str] = None,
|
|
154
|
+
v10_name: Optional[str] = None,
|
|
155
|
+
wpsd10max_name: Optional[str] = None,
|
|
156
|
+
_exclude_other_vars: bool = False,
|
|
152
157
|
) -> xr.Dataset:
|
|
153
158
|
"""
|
|
154
159
|
给xarray.Dataset的风添加属性
|
|
155
160
|
:param _ds: xarray.Dataset
|
|
156
|
-
:param
|
|
157
|
-
:param
|
|
161
|
+
:param u10_name: u10变量名,默认为自动识别
|
|
162
|
+
:param v10_name: v10变量名,默认为自动识别
|
|
163
|
+
:param wpsd10max_name: wpsd10max变量名,默认为自动识别
|
|
164
|
+
:param _exclude_other_vars: 是否排除其他变量,默认为False
|
|
158
165
|
:return: xarray.Dataset
|
|
159
166
|
"""
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
_ds
|
|
167
|
+
u10_name = next((x for x in NAME_u10 if x in _ds.data_vars), None) if u10_name is None else u10_name
|
|
168
|
+
v10_name = next((x for x in NAME_v10 if x in _ds.data_vars), None) if v10_name is None else v10_name
|
|
169
|
+
wpsd10max_name = next((x for x in NAME_wpsd10max if x in _ds.data_vars), None) if wpsd10max_name is None else wpsd10max_name
|
|
170
|
+
_ds[u10_name].attrs = {
|
|
163
171
|
'units': 'm s-1',
|
|
164
172
|
'long_name': '10 meter U wind component',
|
|
165
173
|
'standard_name': 'eastward_wind',
|
|
166
174
|
}
|
|
167
|
-
_ds[
|
|
175
|
+
_ds[v10_name].attrs = {
|
|
168
176
|
'units': 'm s-1',
|
|
169
177
|
'long_name': '10 meter V wind component',
|
|
170
178
|
'standard_name': 'northward_wind',
|
|
171
179
|
}
|
|
172
|
-
dtype = calc_dtype(_ds[
|
|
173
|
-
_ds[
|
|
174
|
-
dtype = calc_dtype(_ds[
|
|
175
|
-
_ds[
|
|
180
|
+
dtype = calc_dtype(_ds[u10_name].data)
|
|
181
|
+
_ds[u10_name].encoding = dict(_FillValue=calc_fillvalue(dtype), dtype=dtype, zlib=True)
|
|
182
|
+
dtype = calc_dtype(_ds[v10_name].data)
|
|
183
|
+
_ds[v10_name].encoding = dict(_FillValue=calc_fillvalue(dtype), dtype=dtype, zlib=True)
|
|
176
184
|
|
|
177
185
|
if 'AGL_heights' in _ds.variables:
|
|
178
186
|
_ds['AGL_heights'].attrs = {
|
|
@@ -180,7 +188,8 @@ def add_wind_attrs(
|
|
|
180
188
|
'long_name': 'Above Ground Level Height',
|
|
181
189
|
'standard_name': 'height',
|
|
182
190
|
}
|
|
183
|
-
|
|
191
|
+
dtype = calc_dtype(_ds['AGL_heights'].data)
|
|
192
|
+
_ds['AGL_heights'].encoding = dict(_FillValue=calc_fillvalue(dtype), dtype=dtype, zlib=True)
|
|
184
193
|
|
|
185
194
|
if 'U_AGL' in _ds.variables and 'V_AGL' in _ds.variables:
|
|
186
195
|
_ds['U_AGL'].attrs = {
|
|
@@ -195,6 +204,7 @@ def add_wind_attrs(
|
|
|
195
204
|
}
|
|
196
205
|
dtype = calc_dtype(_ds['U_AGL'].data)
|
|
197
206
|
_ds['U_AGL'].encoding = dict(_FillValue=calc_fillvalue(dtype), dtype=dtype, zlib=True)
|
|
207
|
+
dtype = calc_dtype(_ds['V_AGL'].data)
|
|
198
208
|
_ds['V_AGL'].encoding = dict(_FillValue=calc_fillvalue(dtype), dtype=dtype, zlib=True)
|
|
199
209
|
|
|
200
210
|
if 'MSL_heights' in _ds.variables:
|
|
@@ -203,7 +213,8 @@ def add_wind_attrs(
|
|
|
203
213
|
'long_name': 'Mean Sea Level Height',
|
|
204
214
|
'standard_name': 'height',
|
|
205
215
|
}
|
|
206
|
-
|
|
216
|
+
dtype = calc_dtype(_ds['MSL_heights'].data)
|
|
217
|
+
_ds['MSL_heights'].encoding = dict(_FillValue=calc_fillvalue(dtype), dtype=dtype, zlib=True)
|
|
207
218
|
|
|
208
219
|
if 'U_MSL' in _ds.variables and 'V_MSL' in _ds.variables:
|
|
209
220
|
_ds['U_MSL'].attrs = {
|
|
@@ -218,203 +229,233 @@ def add_wind_attrs(
|
|
|
218
229
|
}
|
|
219
230
|
dtype = calc_dtype(_ds['U_MSL'].data)
|
|
220
231
|
_ds['U_MSL'].encoding = dict(_FillValue=calc_fillvalue(dtype), dtype=dtype, zlib=True)
|
|
232
|
+
dtype = calc_dtype(_ds['V_MSL'].data)
|
|
221
233
|
_ds['V_MSL'].encoding = dict(_FillValue=calc_fillvalue(dtype), dtype=dtype, zlib=True)
|
|
222
234
|
|
|
223
|
-
if
|
|
224
|
-
_ds[
|
|
235
|
+
if wpsd10max_name in _ds:
|
|
236
|
+
_ds[wpsd10max_name].attrs = {
|
|
225
237
|
'units': 'm s-1',
|
|
226
238
|
'long_name': 'Maximum 10m wind speed',
|
|
227
239
|
'standard_name': 'maximum_10m_wind_speed',
|
|
228
240
|
}
|
|
229
|
-
dtype = calc_dtype(_ds[
|
|
230
|
-
_ds[
|
|
241
|
+
dtype = calc_dtype(_ds[wpsd10max_name].data)
|
|
242
|
+
_ds[wpsd10max_name].encoding = dict(_FillValue=calc_fillvalue(dtype), dtype=dtype, zlib=True)
|
|
243
|
+
|
|
244
|
+
_ds = transpose_dims(_ds)
|
|
231
245
|
|
|
232
246
|
new_order = ['longitude', 'latitude', 'time', 'TIME',
|
|
233
|
-
|
|
247
|
+
u10_name, v10_name,
|
|
234
248
|
'U_AGL', 'V_AGL',
|
|
235
249
|
'U_MSL', 'V_MSL',
|
|
236
|
-
|
|
250
|
+
wpsd10max_name,
|
|
237
251
|
]
|
|
238
|
-
existing_vars = [var for var in new_order if var in _ds.
|
|
239
|
-
|
|
252
|
+
existing_vars = [var for var in new_order if var is not None and var in _ds.variables]
|
|
253
|
+
existing_vars += [var for var in _ds.data_vars if var not in existing_vars] if not _exclude_other_vars else existing_vars
|
|
254
|
+
_ds = _ds[existing_vars]
|
|
240
255
|
|
|
241
256
|
return _ds
|
|
242
257
|
|
|
243
258
|
|
|
244
259
|
def add_temperature_attrs(
|
|
245
260
|
_ds: xr.Dataset,
|
|
246
|
-
|
|
261
|
+
t2_name: Optional[str] = None,
|
|
262
|
+
_exclude_other_vars: bool = False,
|
|
247
263
|
) -> xr.Dataset:
|
|
248
264
|
"""
|
|
249
265
|
给xarray.Dataset的温度添加属性
|
|
250
266
|
:param _ds: xarray.Dataset
|
|
251
|
-
:param
|
|
267
|
+
:param t2_name: T2变量名,默认为自动识别
|
|
268
|
+
:param _exclude_other_vars: 是否排除其他变量,默认为False
|
|
252
269
|
:return: xarray.Dataset
|
|
253
270
|
"""
|
|
254
|
-
|
|
271
|
+
t2_name = next((x for x in NAME_t2 if x in _ds.data_vars), None) if t2_name is None else t2_name
|
|
255
272
|
|
|
256
|
-
_ds[
|
|
273
|
+
_ds[t2_name].attrs = {
|
|
257
274
|
'units': 'K',
|
|
258
275
|
'long_name': 'temperature at 2m',
|
|
259
276
|
'standard_name': 'temperature_at_2m'
|
|
260
277
|
}
|
|
261
|
-
dtype = calc_dtype(_ds[
|
|
262
|
-
_ds[
|
|
278
|
+
dtype = calc_dtype(_ds[t2_name].data)
|
|
279
|
+
_ds[t2_name].encoding = dict(_FillValue=calc_fillvalue(dtype), dtype=dtype, zlib=True)
|
|
263
280
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
281
|
+
_ds = transpose_dims(_ds)
|
|
282
|
+
|
|
283
|
+
new_order = ['longitude', 'latitude', 'time', 'TIME', t2_name]
|
|
284
|
+
existing_vars = [var for var in new_order if var is not None and var in _ds.variables]
|
|
285
|
+
existing_vars += [var for var in _ds.data_vars if var not in existing_vars] if not _exclude_other_vars else existing_vars
|
|
286
|
+
_ds = _ds[existing_vars]
|
|
267
287
|
|
|
268
288
|
return _ds
|
|
269
289
|
|
|
270
290
|
|
|
271
291
|
def add_visibility_attrs(
|
|
272
292
|
_ds: xr.Dataset,
|
|
273
|
-
|
|
293
|
+
visi_name: Optional[str] = None,
|
|
294
|
+
_exclude_other_vars: bool = False,
|
|
274
295
|
) -> xr.Dataset:
|
|
275
296
|
"""
|
|
276
297
|
给xarray.Dataset的能见度添加属性
|
|
277
298
|
:param _ds: xarray.Dataset
|
|
278
|
-
:param
|
|
299
|
+
:param visi_name: 能见度变量名,默认为自动识别
|
|
300
|
+
:param _exclude_other_vars: 是否排除其他变量,默认为False
|
|
279
301
|
:return: xarray.Dataset
|
|
280
302
|
"""
|
|
281
|
-
|
|
303
|
+
visi_name = next((x for x in NAME_visi if x in _ds.data_vars), None) if visi_name is None else visi_name
|
|
282
304
|
|
|
283
|
-
_ds[
|
|
305
|
+
_ds[visi_name].attrs = {
|
|
284
306
|
'units': 'm',
|
|
285
307
|
'long_name': 'visibility',
|
|
286
308
|
'standard_name': 'visibility'
|
|
287
309
|
}
|
|
288
|
-
dtype = calc_dtype(_ds[
|
|
289
|
-
_ds[
|
|
310
|
+
dtype = calc_dtype(_ds[visi_name].data)
|
|
311
|
+
_ds[visi_name].encoding = dict(_FillValue=calc_fillvalue(dtype), dtype=dtype, zlib=True)
|
|
312
|
+
|
|
313
|
+
_ds = transpose_dims(_ds)
|
|
290
314
|
|
|
291
|
-
new_order = ['longitude', 'latitude', 'time', 'TIME',
|
|
292
|
-
existing_vars = [var for var in new_order if var in _ds.
|
|
293
|
-
|
|
315
|
+
new_order = ['longitude', 'latitude', 'time', 'TIME', visi_name]
|
|
316
|
+
existing_vars = [var for var in new_order if var is not None and var in _ds.variables]
|
|
317
|
+
existing_vars += [var for var in _ds.data_vars if var not in existing_vars] if not _exclude_other_vars else existing_vars
|
|
318
|
+
_ds = _ds[existing_vars]
|
|
294
319
|
|
|
295
320
|
return _ds
|
|
296
321
|
|
|
297
322
|
|
|
298
323
|
def add_radiation_attrs(
|
|
299
324
|
_ds: xr.Dataset,
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
325
|
+
swr_name: Optional[str] = None,
|
|
326
|
+
lwr_name: Optional[str] = None,
|
|
327
|
+
swrn_name: Optional[str] = None,
|
|
328
|
+
_exclude_other_vars: bool = False,
|
|
303
329
|
) -> xr.Dataset:
|
|
304
330
|
"""
|
|
305
331
|
给xarray.Dataset的辐射添加属性
|
|
306
332
|
:param _ds: xarray.Dataset
|
|
307
|
-
:param
|
|
308
|
-
:param
|
|
309
|
-
:param
|
|
333
|
+
:param swr_name: 短波辐射变量名,默认为自动识别
|
|
334
|
+
:param lwr_name: 长波辐射变量名,默认为自动识别
|
|
335
|
+
:param swrn_name: 短波辐射法向量变量名,默认为自动识别
|
|
336
|
+
:param _exclude_other_vars: 是否排除其他变量,默认为False
|
|
310
337
|
:return: xarray.Dataset
|
|
311
338
|
"""
|
|
312
|
-
|
|
313
|
-
|
|
339
|
+
swr_name = next((x for x in NAME_swr if x in _ds.data_vars), None) if swr_name is None else swr_name
|
|
340
|
+
lwr_name = next((x for x in NAME_lwr if x in _ds.data_vars), None) if lwr_name is None else lwr_name
|
|
341
|
+
swrn_name = next((x for x in NAME_swrn if x in _ds.data_vars), None) if swrn_name is None else swrn_name
|
|
314
342
|
|
|
315
|
-
_ds[
|
|
343
|
+
_ds[swr_name].attrs = {
|
|
316
344
|
'units': 'W/m^2',
|
|
317
345
|
'long_name': 'Short wave radiation',
|
|
318
346
|
'standard_name': 'Short_wave_radiation',
|
|
319
347
|
'description': 'Short wave radiation, positive for ocean gaining energy',
|
|
320
348
|
}
|
|
321
|
-
dtype = calc_dtype(_ds[
|
|
322
|
-
_ds[
|
|
349
|
+
dtype = calc_dtype(_ds[swr_name].data)
|
|
350
|
+
_ds[swr_name].encoding = dict(_FillValue=calc_fillvalue(dtype), dtype=dtype, zlib=True)
|
|
323
351
|
|
|
324
|
-
_ds[
|
|
352
|
+
_ds[lwr_name].attrs = {
|
|
325
353
|
'units': 'W/m^2',
|
|
326
354
|
'long_name': 'Long wave radiation',
|
|
327
355
|
'standard_name': 'Long_wave_radiation',
|
|
328
356
|
'description': 'Long wave radiation, positive for ocean gaining energy',
|
|
329
357
|
}
|
|
330
|
-
dtype = calc_dtype(_ds[
|
|
331
|
-
_ds[
|
|
358
|
+
dtype = calc_dtype(_ds[lwr_name].data)
|
|
359
|
+
_ds[lwr_name].encoding = dict(_FillValue=calc_fillvalue(dtype), dtype=dtype, zlib=True)
|
|
332
360
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
_ds[swnorm_name].attrs = {
|
|
361
|
+
if swrn_name in _ds:
|
|
362
|
+
_ds[swrn_name].attrs = {
|
|
336
363
|
'units': 'W/m^2',
|
|
337
364
|
'long_name': 'Short wave radiation normal',
|
|
338
365
|
'standard_name': 'Short_wave_radiation_normal',
|
|
339
366
|
'description': 'normal short wave flux at ground surface (slope-dependent)',
|
|
340
367
|
}
|
|
341
|
-
dtype = calc_dtype(_ds[
|
|
342
|
-
_ds[
|
|
368
|
+
dtype = calc_dtype(_ds[swrn_name].data)
|
|
369
|
+
_ds[swrn_name].encoding = dict(_FillValue=calc_fillvalue(dtype), dtype=dtype, zlib=True)
|
|
343
370
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
371
|
+
_ds = transpose_dims(_ds)
|
|
372
|
+
|
|
373
|
+
new_order = ['longitude', 'latitude', 'time', 'TIME', swr_name, lwr_name, swrn_name]
|
|
374
|
+
existing_vars = [var for var in new_order if var is not None and var in _ds.variables]
|
|
375
|
+
existing_vars += [var for var in _ds.data_vars if var not in existing_vars] if not _exclude_other_vars else existing_vars
|
|
376
|
+
_ds = _ds[existing_vars]
|
|
348
377
|
|
|
349
378
|
return _ds
|
|
350
379
|
|
|
351
380
|
|
|
352
381
|
def add_cloudCover_attrs(
|
|
353
382
|
_ds: xr.Dataset,
|
|
354
|
-
|
|
383
|
+
tcc_name: Optional[str] = None,
|
|
384
|
+
_exclude_other_vars: bool = False,
|
|
355
385
|
) -> xr.Dataset:
|
|
356
386
|
"""
|
|
357
387
|
给xarray.Dataset的云量添加属性
|
|
358
388
|
:param _ds: xarray.Dataset
|
|
359
|
-
:param
|
|
389
|
+
:param tcc_name: 云量变量名,默认为自动识别
|
|
390
|
+
:param _exclude_other_vars: 是否排除其他变量,默认为False
|
|
360
391
|
:return: xarray.Dataset
|
|
361
392
|
"""
|
|
362
|
-
|
|
393
|
+
tcc_name = next((x for x in NAME_tcc if x in _ds.data_vars), None) if tcc_name is None else tcc_name
|
|
363
394
|
|
|
364
|
-
_ds[
|
|
395
|
+
_ds[tcc_name].attrs = {
|
|
365
396
|
'units': '1',
|
|
366
397
|
'long_name': 'total cloud cover',
|
|
367
398
|
'standard_name': 'total_cloud_cover',
|
|
368
399
|
'description': 'Total cloud cover, percentage of the sky covered by clouds'
|
|
369
400
|
}
|
|
370
|
-
dtype = calc_dtype(_ds[
|
|
371
|
-
_ds[
|
|
401
|
+
dtype = calc_dtype(_ds[tcc_name].data)
|
|
402
|
+
_ds[tcc_name].encoding = dict(_FillValue=calc_fillvalue(dtype), dtype=dtype, zlib=True)
|
|
403
|
+
|
|
404
|
+
_ds = transpose_dims(_ds)
|
|
372
405
|
|
|
373
|
-
new_order = ['longitude', 'latitude', 'time', 'TIME',
|
|
374
|
-
existing_vars = [var for var in new_order if var in _ds.
|
|
375
|
-
|
|
406
|
+
new_order = ['longitude', 'latitude', 'time', 'TIME', tcc_name]
|
|
407
|
+
existing_vars = [var for var in new_order if var is not None and var in _ds.variables]
|
|
408
|
+
existing_vars += [var for var in _ds.data_vars if var not in existing_vars] if not _exclude_other_vars else existing_vars
|
|
409
|
+
_ds = _ds[existing_vars]
|
|
376
410
|
|
|
377
411
|
return _ds
|
|
378
412
|
|
|
379
413
|
|
|
380
414
|
def add_precipitation_attrs(
|
|
381
415
|
_ds: xr.Dataset,
|
|
382
|
-
|
|
416
|
+
prec_name: Optional[str] = None,
|
|
417
|
+
_exclude_other_vars: bool = False,
|
|
383
418
|
) -> xr.Dataset:
|
|
384
419
|
"""
|
|
385
420
|
给xarray.Dataset的降水添加属性
|
|
386
421
|
:param _ds: xarray.Dataset
|
|
387
|
-
:param
|
|
422
|
+
:param prec_name: 降水变量名,默认为自动识别
|
|
423
|
+
:param _exclude_other_vars: 是否排除其他变量,默认为False
|
|
388
424
|
:return: xarray.Dataset
|
|
389
425
|
"""
|
|
390
|
-
|
|
426
|
+
prec_name = next((x for x in NAME_prec if x in _ds.data_vars), None) if prec_name is None else prec_name
|
|
391
427
|
|
|
392
|
-
_ds[
|
|
428
|
+
_ds[prec_name].attrs = {
|
|
393
429
|
'units': 'mm',
|
|
394
430
|
'long_name': 'precipitation, positive for ocean gaining water',
|
|
395
431
|
'standard_name': 'precipitation_positive_ocean_gaining_water'
|
|
396
432
|
}
|
|
397
|
-
dtype = calc_dtype(_ds[
|
|
398
|
-
_ds[
|
|
433
|
+
dtype = calc_dtype(_ds[prec_name].data)
|
|
434
|
+
_ds[prec_name].encoding = dict(_FillValue=calc_fillvalue(dtype), dtype=dtype, zlib=True)
|
|
399
435
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
436
|
+
_ds = transpose_dims(_ds)
|
|
437
|
+
|
|
438
|
+
new_order = ['longitude', 'latitude', 'time', 'TIME', prec_name]
|
|
439
|
+
existing_vars = [var for var in new_order if var is not None and var in _ds.variables]
|
|
440
|
+
existing_vars += [var for var in _ds.data_vars if var not in existing_vars] if not _exclude_other_vars else existing_vars
|
|
441
|
+
_ds = _ds[existing_vars]
|
|
403
442
|
|
|
404
443
|
return _ds
|
|
405
444
|
|
|
406
445
|
|
|
407
446
|
def add_slp_attrs(
|
|
408
447
|
_ds: xr.Dataset,
|
|
409
|
-
slp_name: Optional[str] = None
|
|
448
|
+
slp_name: Optional[str] = None,
|
|
449
|
+
_exclude_other_vars: bool = False,
|
|
410
450
|
) -> xr.Dataset:
|
|
411
451
|
"""
|
|
412
452
|
给xarray.Dataset的海平面气压添加属性
|
|
413
453
|
:param _ds: xarray.Dataset
|
|
414
454
|
:param slp_name: 海平面气压变量名,默认为自动识别
|
|
455
|
+
:param _exclude_other_vars: 是否排除其他变量,默认为False
|
|
415
456
|
:return: xarray.Dataset
|
|
416
457
|
"""
|
|
417
|
-
slp_name = next((x for x in
|
|
458
|
+
slp_name = next((x for x in NAME_slp if x in _ds.data_vars), None) if slp_name is None else slp_name
|
|
418
459
|
|
|
419
460
|
_ds[slp_name].attrs = {
|
|
420
461
|
'units': 'Pa',
|
|
@@ -424,9 +465,12 @@ def add_slp_attrs(
|
|
|
424
465
|
dtype = calc_dtype(_ds[slp_name].data)
|
|
425
466
|
_ds[slp_name].encoding = dict(_FillValue=calc_fillvalue(dtype), dtype=dtype, zlib=True)
|
|
426
467
|
|
|
468
|
+
_ds = transpose_dims(_ds)
|
|
469
|
+
|
|
427
470
|
new_order = ['longitude', 'latitude', 'time', 'TIME', slp_name]
|
|
428
|
-
existing_vars = [var for var in new_order if var in _ds.
|
|
429
|
-
|
|
471
|
+
existing_vars = [var for var in new_order if var is not None and var in _ds.variables]
|
|
472
|
+
existing_vars += [var for var in _ds.data_vars if var not in existing_vars] if not _exclude_other_vars else existing_vars
|
|
473
|
+
_ds = _ds[existing_vars]
|
|
430
474
|
|
|
431
475
|
return _ds
|
|
432
476
|
|
|
@@ -444,7 +488,8 @@ def add_wave_attrs(
|
|
|
444
488
|
mpww_name: Optional[str] = None,
|
|
445
489
|
mpts_name: Optional[str] = None,
|
|
446
490
|
pp1d_name: Optional[str] = None,
|
|
447
|
-
hmax_name: Optional[str] = None
|
|
491
|
+
hmax_name: Optional[str] = None,
|
|
492
|
+
_exclude_other_vars: bool = False,
|
|
448
493
|
) -> xr.Dataset:
|
|
449
494
|
"""
|
|
450
495
|
给xarray.Dataset的海浪添加属性
|
|
@@ -461,22 +506,23 @@ def add_wave_attrs(
|
|
|
461
506
|
:param mpts_name: 涌浪平均波周期变量名,默认为自动识别
|
|
462
507
|
:param pp1d_name: 谱峰周期变量名,默认为自动识别
|
|
463
508
|
:param hmax_name: 最大波高变量名,默认为自动识别
|
|
509
|
+
:param _exclude_other_vars: 是否排除其他变量,默认为False
|
|
464
510
|
:return: xarray.Dataset
|
|
465
511
|
"""
|
|
466
|
-
swh_name = next((x for x in
|
|
467
|
-
mwp_name = next((x for x in
|
|
468
|
-
mwd_name = next((x for x in
|
|
469
|
-
mwl_name = next((x for x in
|
|
470
|
-
|
|
471
|
-
shww_name = next((x for x in
|
|
472
|
-
shts_name = next((x for x in
|
|
473
|
-
mdww_name = next((x for x in
|
|
474
|
-
mdts_name = next((x for x in
|
|
475
|
-
mpww_name = next((x for x in
|
|
476
|
-
mpts_name = next((x for x in
|
|
477
|
-
|
|
478
|
-
pp1d_name = next((x for x in
|
|
479
|
-
hmax_name = next((x for x in
|
|
512
|
+
swh_name = next((x for x in NAME_swh if x in _ds.data_vars), None) if swh_name is None else swh_name
|
|
513
|
+
mwp_name = next((x for x in NAME_mwp if x in _ds.data_vars), None) if mwp_name is None else mwp_name
|
|
514
|
+
mwd_name = next((x for x in NAME_mwd if x in _ds.data_vars), None) if mwd_name is None else mwd_name
|
|
515
|
+
mwl_name = next((x for x in NAME_mwl if x in _ds.data_vars), None) if mwl_name is None else mwl_name
|
|
516
|
+
|
|
517
|
+
shww_name = next((x for x in NAME_shww if x in _ds.data_vars), None) if shww_name is None else shww_name # 风浪有效波高
|
|
518
|
+
shts_name = next((x for x in NAME_shts if x in _ds.data_vars), None) if shts_name is None else shts_name # 涌浪有效波高
|
|
519
|
+
mdww_name = next((x for x in NAME_mdww if x in _ds.data_vars), None) if mdww_name is None else mdww_name # 风浪平均波向
|
|
520
|
+
mdts_name = next((x for x in NAME_mdts if x in _ds.data_vars), None) if mdts_name is None else mdts_name # 涌浪平均波向
|
|
521
|
+
mpww_name = next((x for x in NAME_mpww if x in _ds.data_vars), None) if mpww_name is None else mpww_name # 风浪平均波周期
|
|
522
|
+
mpts_name = next((x for x in NAME_mpts if x in _ds.data_vars), None) if mpts_name is None else mpts_name # 涌浪平均波周期
|
|
523
|
+
|
|
524
|
+
pp1d_name = next((x for x in NAME_pp1d if x in _ds.data_vars), None) if pp1d_name is None else pp1d_name # 谱峰周期
|
|
525
|
+
hmax_name = next((x for x in NAME_hmax if x in _ds.data_vars), None) if hmax_name is None else hmax_name # 最大波高
|
|
480
526
|
|
|
481
527
|
if swh_name in _ds:
|
|
482
528
|
_ds[swh_name].attrs = {
|
|
@@ -593,6 +639,8 @@ def add_wave_attrs(
|
|
|
593
639
|
dtype = calc_dtype(_ds[hmax_name].data)
|
|
594
640
|
_ds[hmax_name].encoding = dict(_FillValue=calc_fillvalue(dtype), dtype=dtype, zlib=True)
|
|
595
641
|
|
|
642
|
+
_ds = transpose_dims(_ds)
|
|
643
|
+
|
|
596
644
|
new_order = ['longitude', 'latitude', 'time', 'TIME',
|
|
597
645
|
swh_name, mwp_name, mwd_name,
|
|
598
646
|
mwl_name, pp1d_name, hmax_name,
|
|
@@ -600,8 +648,9 @@ def add_wave_attrs(
|
|
|
600
648
|
mdww_name, mdts_name,
|
|
601
649
|
mpww_name, mpts_name,
|
|
602
650
|
]
|
|
603
|
-
existing_vars = [var for var in new_order if var in _ds.
|
|
604
|
-
|
|
651
|
+
existing_vars = [var for var in new_order if var is not None and var in _ds.variables]
|
|
652
|
+
existing_vars += [var for var in _ds.data_vars if var not in existing_vars] if not _exclude_other_vars else existing_vars
|
|
653
|
+
_ds = _ds[existing_vars]
|
|
605
654
|
|
|
606
655
|
return _ds
|
|
607
656
|
|
|
@@ -609,17 +658,19 @@ def add_wave_attrs(
|
|
|
609
658
|
def add_ice_attrs(
|
|
610
659
|
_ds: xr.Dataset,
|
|
611
660
|
aice_name: Optional[str] = None,
|
|
612
|
-
tice_name: Optional[str] = None
|
|
661
|
+
tice_name: Optional[str] = None,
|
|
662
|
+
_exclude_other_vars: bool = False,
|
|
613
663
|
) -> xr.Dataset:
|
|
614
664
|
"""
|
|
615
665
|
给xarray.Dataset的海冰添加属性
|
|
616
666
|
:param _ds: xarray.Dataset
|
|
617
667
|
:param aice_name: 海冰浓度变量名,默认为自动识别
|
|
618
668
|
:param tice_name: 海冰厚度变量名,默认为自动识别
|
|
669
|
+
:param _exclude_other_vars: 是否排除其他变量,默认为False
|
|
619
670
|
:return: xarray.Dataset
|
|
620
671
|
"""
|
|
621
|
-
aice_name = next((x for x in
|
|
622
|
-
tice_name = next((x for x in
|
|
672
|
+
aice_name = next((x for x in NAME_aice if x in _ds.data_vars), None) if aice_name is None else aice_name
|
|
673
|
+
tice_name = next((x for x in NAME_tice if x in _ds.data_vars), None) if tice_name is None else tice_name
|
|
623
674
|
|
|
624
675
|
if aice_name in _ds:
|
|
625
676
|
_ds[aice_name].attrs = {
|
|
@@ -639,17 +690,52 @@ def add_ice_attrs(
|
|
|
639
690
|
dtype = calc_dtype(_ds[tice_name].data)
|
|
640
691
|
_ds[tice_name].encoding = dict(_FillValue=calc_fillvalue(dtype), dtype=dtype, zlib=True)
|
|
641
692
|
|
|
693
|
+
_ds = transpose_dims(_ds)
|
|
694
|
+
|
|
642
695
|
new_order = ['longitude', 'latitude', 'time', 'TIME', aice_name, tice_name]
|
|
643
|
-
existing_vars = [var for var in new_order if var in _ds.
|
|
644
|
-
|
|
696
|
+
existing_vars = [var for var in new_order if var is not None and var in _ds.variables]
|
|
697
|
+
existing_vars += [var for var in _ds.data_vars if var not in existing_vars] if not _exclude_other_vars else existing_vars
|
|
698
|
+
_ds = _ds[existing_vars]
|
|
645
699
|
|
|
646
700
|
return _ds
|
|
647
701
|
|
|
648
702
|
|
|
703
|
+
def transpose_dims(_ds: xr.Dataset) -> xr.Dataset:
|
|
704
|
+
"""
|
|
705
|
+
转置xarray.Dataset的维度顺序为(time, latitude, longitude)
|
|
706
|
+
"""
|
|
707
|
+
transpose_order = []
|
|
708
|
+
|
|
709
|
+
if 'time' in _ds.dims:
|
|
710
|
+
transpose_order.append('time')
|
|
711
|
+
|
|
712
|
+
# 除 time / latitude / longitude / 字符串辅助维度外,其他维度放在 time 后面。
|
|
713
|
+
# 例如 U_AGL(AGL_heights, time, latitude, longitude)
|
|
714
|
+
# 会变成 U_AGL(time, AGL_heights, latitude, longitude)。
|
|
715
|
+
for _dim in _ds.dims:
|
|
716
|
+
if _dim not in ['time', 'latitude', 'longitude', 'TIME', 'DateStr']:
|
|
717
|
+
transpose_order.append(_dim)
|
|
718
|
+
|
|
719
|
+
for _dim in ['latitude', 'longitude']:
|
|
720
|
+
if _dim in _ds.dims:
|
|
721
|
+
transpose_order.append(_dim)
|
|
722
|
+
|
|
723
|
+
# 如果仍然存在 TIME / DateStr 这类字符辅助维度,放到开头,避免影响数值变量的 time-first 结构。
|
|
724
|
+
for _dim in ['TIME', 'DateStr']:
|
|
725
|
+
if _dim in _ds.dims:
|
|
726
|
+
transpose_order.insert(0, _dim)
|
|
727
|
+
|
|
728
|
+
return _ds.transpose(*transpose_order)
|
|
729
|
+
|
|
730
|
+
|
|
649
731
|
def fixed_encoding(_ds, **kwargs):
|
|
650
732
|
"""
|
|
651
733
|
修正xarray.Dataset的encoding
|
|
652
734
|
"""
|
|
735
|
+
|
|
736
|
+
# 给global arttributes添加 Alaea_version 属性,方便追踪数据来源 为pip安装的版本号,或者直接从GitHub下载的版本号。
|
|
737
|
+
_ds.attrs['Alaea_version'] = version('Alaea')
|
|
738
|
+
|
|
653
739
|
_ds.encoding['unlimited_dims'] = kwargs.get('unlimited_dims', 'time')
|
|
654
740
|
_ds.encoding['format'] = kwargs.get('format', 'NETCDF4')
|
|
655
741
|
_ds.encoding['engine'] = kwargs.get('engine', 'netcdf4')
|
|
@@ -732,19 +818,19 @@ def calc_dtype(_values) -> type:
|
|
|
732
818
|
|
|
733
819
|
返回值为 NumPy 类型对象(如 np.float32 / np.int32),便于直接配合 np.finfo() / np.iinfo() 使用。
|
|
734
820
|
|
|
735
|
-
NetCDF类型 C类型 numpy类型 / dtype MATLAB类型
|
|
736
|
-
byte signed char np.int8 int8 1 NetCDF3/4 有符号 8 位整数
|
|
737
|
-
short short np.int16 int16 2 NetCDF3/4 有符号 16 位整数
|
|
738
|
-
int int np.int32 int32 4 NetCDF3/4 有符号 32 位整数
|
|
739
|
-
int64 long long np.int64 int64 8 NetCDF4 有符号 64 位整数
|
|
740
|
-
ubyte unsigned char np.uint8 uint8 1 NetCDF4 无符号 8 位整数
|
|
741
|
-
ushort unsigned short np.uint16 uint16 2 NetCDF4 无符号 16 位整数
|
|
742
|
-
uint unsigned int np.uint32 uint32 4 NetCDF4 无符号 32 位整数
|
|
743
|
-
uint64 unsigned long long np.uint64 uint64 8 NetCDF4 无符号 64 位整数
|
|
744
|
-
float float np.float32 single 4 单精度浮点
|
|
745
|
-
double double np.float64 double 8 双精度浮点
|
|
746
|
-
char char 'S1' / '|S1' char 1 单个字符(NetCDF classic 字符类型)
|
|
747
|
-
string - <U19 / str> / object string
|
|
821
|
+
NetCDF类型 C类型 numpy类型 / dtype MATLAB类型1 MATLAB类型2 默认缺测值常量 字节数 说明
|
|
822
|
+
byte signed char np.int8 int8 NC_BYTE NC_FILL_BYTE 1 NetCDF3/4 有符号 8 位整数
|
|
823
|
+
short short np.int16 int16 NC_SHORT NC_FILL_SHORT 2 NetCDF3/4 有符号 16 位整数
|
|
824
|
+
int int np.int32 int32 NC_INT NC_FILL_INT 4 NetCDF3/4 有符号 32 位整数
|
|
825
|
+
int64 long long np.int64 int64 NC_INT64 NC_FILL_INT64 8 NetCDF4 有符号 64 位整数
|
|
826
|
+
ubyte unsigned char np.uint8 uint8 NC_UBYTE NC_FILL_UBYTE 1 NetCDF4 无符号 8 位整数
|
|
827
|
+
ushort unsigned short np.uint16 uint16 NC_USHORT NC_FILL_USHORT 2 NetCDF4 无符号 16 位整数
|
|
828
|
+
uint unsigned int np.uint32 uint32 NC_UINT NC_FILL_UINT 4 NetCDF4 无符号 32 位整数
|
|
829
|
+
uint64 unsigned long long np.uint64 uint64 NC_UINT64 NC_FILL_UINT64 8 NetCDF4 无符号 64 位整数
|
|
830
|
+
float float np.float32 single NC_FLOAT NC_FILL_FLOAT 4 单精度浮点
|
|
831
|
+
double double np.float64 double NC_DOUBLE NC_FILL_DOUBLE 8 双精度浮点
|
|
832
|
+
char char 'S1' / '|S1' char NC_CHAR NC_FILL_CHAR 1 单个字符(NetCDF classic 字符类型)
|
|
833
|
+
string - <U19 / str> / object string NC_STRING NC_FILL_STRING 变长 xarray/Python 字符串;NetCDF4 常为变长字符串
|
|
748
834
|
|
|
749
835
|
补充:
|
|
750
836
|
- dtype='S19' / '|S19':固定长度 19 的字节串(bytes),总字节数 19
|
|
@@ -794,6 +880,7 @@ def calc_dtype(_values) -> type:
|
|
|
794
880
|
# 其他情况兜底
|
|
795
881
|
return np.float32
|
|
796
882
|
|
|
883
|
+
|
|
797
884
|
def calc_fillvalue(_dtype):
|
|
798
885
|
"""
|
|
799
886
|
根据数据类型计算合适的_FillValue
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
"""
|
|
10
10
|
|
|
11
11
|
"""
|
|
12
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
13
|
+
|
|
12
14
|
from .Blogging import *
|
|
13
15
|
from .commonCode import *
|
|
14
16
|
from .cprintfs import *
|
|
@@ -20,3 +22,9 @@ from .SameAsMATLAB import *
|
|
|
20
22
|
from .server_info import *
|
|
21
23
|
from .Standard import *
|
|
22
24
|
from .tools import *
|
|
25
|
+
|
|
26
|
+
try:
|
|
27
|
+
__version__ = version('Alaea')
|
|
28
|
+
except PackageNotFoundError:
|
|
29
|
+
__version__ = 'unknown'
|
|
30
|
+
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|