geospacelab 0.11.4__py3-none-any.whl → 0.12.0__py3-none-any.whl

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.
Files changed (63) hide show
  1. geospacelab/__init__.py +1 -1
  2. geospacelab/datahub/sources/cdaweb/dmsp/ssusi/downloader.py +103 -0
  3. geospacelab/datahub/sources/cdaweb/dmsp/ssusi/edr_aur/__init__.py +17 -7
  4. geospacelab/datahub/sources/cdaweb/dmsp/ssusi/edr_aur/downloader.py +13 -62
  5. geospacelab/datahub/sources/cdaweb/dmsp/ssusi/sdr_disk/__init__.py +317 -0
  6. geospacelab/datahub/sources/cdaweb/dmsp/ssusi/sdr_disk/downloader.py +44 -0
  7. geospacelab/datahub/sources/cdaweb/dmsp/ssusi/sdr_disk/loader.py +198 -0
  8. geospacelab/datahub/sources/cdaweb/dmsp/ssusi/sdr_disk/variable_config.py +149 -0
  9. geospacelab/datahub/sources/cdaweb/downloader.py +396 -97
  10. geospacelab/datahub/sources/cdaweb/downloader_backup.py +93 -0
  11. geospacelab/datahub/sources/cdaweb/omni/__init__.py +26 -14
  12. geospacelab/datahub/sources/cdaweb/omni/downloader.py +97 -84
  13. geospacelab/datahub/sources/esa_eo/swarm/advanced/efi_tct02/__init__.py +1 -1
  14. geospacelab/datahub/sources/esa_eo/swarm/advanced/efi_tct02/downloader.py +1 -1
  15. geospacelab/datahub/sources/gfz/hpo/__init__.py +1 -1
  16. geospacelab/datahub/sources/gfz/hpo/variable_config.py +3 -1
  17. geospacelab/datahub/sources/madrigal/isr/pfisr/fitted/loader.py +1 -1
  18. geospacelab/datahub/sources/madrigal/satellites/dmsp/downloader.py +2 -1
  19. geospacelab/datahub/sources/tud/champ/dns_acc/__init__.py +24 -7
  20. geospacelab/datahub/sources/tud/champ/dns_acc/downloader.py +29 -36
  21. geospacelab/datahub/sources/tud/champ/dns_acc/loader.py +28 -2
  22. geospacelab/datahub/sources/tud/champ/wnd_acc/__init__.py +68 -10
  23. geospacelab/datahub/sources/tud/champ/wnd_acc/downloader.py +29 -36
  24. geospacelab/datahub/sources/tud/champ/wnd_acc/loader.py +36 -7
  25. geospacelab/datahub/sources/tud/champ/wnd_acc/variable_config.py +3 -3
  26. geospacelab/datahub/sources/tud/downloader.py +288 -113
  27. geospacelab/datahub/sources/tud/goce/dns_acc/__init__.py +354 -0
  28. geospacelab/datahub/sources/tud/goce/dns_acc/downloader.py +42 -0
  29. geospacelab/datahub/sources/tud/goce/dns_acc/loader.py +66 -0
  30. geospacelab/datahub/sources/tud/goce/dns_acc/variable_config.py +139 -0
  31. geospacelab/datahub/sources/tud/goce/dns_wnd_acc/__init__.py +3 -3
  32. geospacelab/datahub/sources/tud/goce/dns_wnd_acc_v01/__init__.py +339 -0
  33. geospacelab/datahub/sources/tud/goce/dns_wnd_acc_v01/downloader.py +42 -0
  34. geospacelab/datahub/sources/tud/goce/dns_wnd_acc_v01/loader.py +84 -0
  35. geospacelab/datahub/sources/tud/goce/dns_wnd_acc_v01/variable_config.py +212 -0
  36. geospacelab/datahub/sources/tud/goce/wnd_acc/__init__.py +339 -0
  37. geospacelab/datahub/sources/tud/goce/wnd_acc/downloader.py +42 -0
  38. geospacelab/datahub/sources/tud/goce/wnd_acc/loader.py +65 -0
  39. geospacelab/datahub/sources/tud/goce/wnd_acc/variable_config.py +188 -0
  40. geospacelab/datahub/sources/tud/grace/dns_acc/__init__.py +6 -3
  41. geospacelab/datahub/sources/tud/grace/dns_acc/downloader.py +29 -37
  42. geospacelab/datahub/sources/tud/grace/wnd_acc/__init__.py +21 -4
  43. geospacelab/datahub/sources/tud/grace/wnd_acc/downloader.py +29 -39
  44. geospacelab/datahub/sources/tud/grace/wnd_acc/loader.py +5 -1
  45. geospacelab/datahub/sources/tud/grace/wnd_acc/variable_config.py +74 -0
  46. geospacelab/datahub/sources/tud/grace_fo/dns_acc/__init__.py +6 -3
  47. geospacelab/datahub/sources/tud/grace_fo/dns_acc/downloader.py +35 -40
  48. geospacelab/datahub/sources/tud/grace_fo/wnd_acc/__init__.py +20 -4
  49. geospacelab/datahub/sources/tud/grace_fo/wnd_acc/downloader.py +29 -44
  50. geospacelab/datahub/sources/tud/grace_fo/wnd_acc/loader.py +4 -0
  51. geospacelab/datahub/sources/tud/grace_fo/wnd_acc/variable_config.py +73 -0
  52. geospacelab/datahub/sources/tud/swarm/dns_acc/__init__.py +27 -5
  53. geospacelab/datahub/sources/tud/swarm/dns_acc/downloader.py +29 -38
  54. geospacelab/datahub/sources/tud/swarm/dns_pod/__init__.py +24 -5
  55. geospacelab/datahub/sources/tud/swarm/dns_pod/downloader.py +29 -38
  56. geospacelab/datahub/sources/tud/swarm/dns_pod/loader.py +3 -0
  57. geospacelab/datahub/sources/wdc/asysym/downloader.py +2 -2
  58. geospacelab/visualization/mpl/panels.py +7 -3
  59. {geospacelab-0.11.4.dist-info → geospacelab-0.12.0.dist-info}/METADATA +1 -1
  60. {geospacelab-0.11.4.dist-info → geospacelab-0.12.0.dist-info}/RECORD +63 -45
  61. {geospacelab-0.11.4.dist-info → geospacelab-0.12.0.dist-info}/WHEEL +1 -1
  62. {geospacelab-0.11.4.dist-info → geospacelab-0.12.0.dist-info}/licenses/LICENSE +0 -0
  63. {geospacelab-0.11.4.dist-info → geospacelab-0.12.0.dist-info}/top_level.txt +0 -0
@@ -25,7 +25,7 @@ default_dataset_attrs = {
25
25
  'instrument': 'ACC',
26
26
  'product': 'WND-ACC',
27
27
  'data_file_ext': 'txt',
28
- 'product_version': 'v01',
28
+ 'product_version': 'v02',
29
29
  'data_root_dir': prf.datahub_data_root_dir / 'TUD' / 'CHAMP',
30
30
  'allow_load': True,
31
31
  'allow_download': True,
@@ -38,19 +38,38 @@ default_dataset_attrs = {
38
38
  'time_clip': True,
39
39
  }
40
40
 
41
- default_variable_names_v01 = [
41
+ default_variable_names_v01 = [
42
42
  'SC_DATETIME',
43
43
  'SC_GEO_LAT',
44
44
  'SC_GEO_LON',
45
45
  'SC_GEO_ALT',
46
46
  'SC_ARG_LAT',
47
47
  'SC_GEO_LST',
48
+ 'u_CROSS',
49
+ 'UNIT_VECTOR_N',
50
+ 'UNIT_VECTOR_E',
51
+ 'UNIT_VECTOR_D',
48
52
  'u_CROSS_N',
49
53
  'u_CROSS_E',
50
- 'u_CROSS_U',
54
+ 'u_CROSS_D',
55
+ ]
56
+ default_variable_names_v02 = [
57
+ 'SC_DATETIME',
58
+ 'SC_GEO_LAT',
59
+ 'SC_GEO_LON',
60
+ 'SC_GEO_ALT',
61
+ 'SC_ARG_LAT',
62
+ 'SC_GEO_LST',
51
63
  'u_CROSS',
64
+ 'UNIT_VECTOR_N',
65
+ 'UNIT_VECTOR_E',
66
+ 'UNIT_VECTOR_D',
67
+ 'u_CROSS_N',
68
+ 'u_CROSS_E',
69
+ 'u_CROSS_D',
70
+ 'FLAG',
52
71
  ]
53
- default_variable_names_v02 = []
72
+
54
73
 
55
74
  # default_data_search_recursive = True
56
75
 
@@ -67,10 +86,12 @@ class Dataset(datahub.DatasetSourced):
67
86
  self.facility = kwargs.pop('facility', 'CHAMP')
68
87
  self.instrument = kwargs.pop('instrument', 'ACC')
69
88
  self.product = kwargs.pop('product', 'WND-ACC')
70
- self.product_version = kwargs.pop('product_version', 'v01')
89
+ self.product_version = kwargs.pop('product_version', 'v02')
71
90
  self.local_latest_version = ''
72
91
  self.allow_download = kwargs.pop('allow_download', False)
73
92
  self.force_download = kwargs.pop('force_download', False)
93
+ self.download_dry_run = kwargs.pop('download_dry_run', False)
94
+
74
95
  self.add_AACGM = kwargs.pop('add_AACGM', False)
75
96
  self.add_APEX = kwargs.pop('add_APEX', False)
76
97
  self._data_root_dir = self.data_root_dir # Record the initial root dir
@@ -130,7 +151,41 @@ class Dataset(datahub.DatasetSourced):
130
151
 
131
152
  if self.add_APEX:
132
153
  self.convert_to_APEX()
133
-
154
+ self._add_u_CT()
155
+
156
+ def _add_u_CT(self):
157
+ from geospacelab.observatory.orbit.utilities import LEOToolbox
158
+ ds_leo = LEOToolbox(self.dt_fr, self.dt_to)
159
+ ds_leo.clone_variables(self)
160
+
161
+ wind_unit_vector = np.concatenate(
162
+ (
163
+ self['UNIT_VECTOR_N'].value,
164
+ self['UNIT_VECTOR_E'].value,
165
+ self['UNIT_VECTOR_D'].value
166
+ ),
167
+ axis=1
168
+ )
169
+ orbit_unit_vector = ds_leo.trajectory_local_unit_vector()
170
+ cp = np.cross(orbit_unit_vector, wind_unit_vector)
171
+ u_CT = -np.sign(cp[:, 2]) * (
172
+ (self['u_CROSS'].value.flatten() * self['UNIT_VECTOR_N'].flatten()) ** 2 +
173
+ (self['u_CROSS'].value.flatten() * self['UNIT_VECTOR_E'].flatten()) ** 2) ** 0.5
174
+ u_VCT = self['u_CROSS'].value.flatten() * self['UNIT_VECTOR_D'].flatten()
175
+
176
+ var = self['u_CROSS'].clone()
177
+ var.name = 'u_CT'
178
+ var.label = r'$u_{CT}$'
179
+ var.visual.axis[1].lim = [None, None]
180
+ var.value = u_CT[:, np.newaxis]
181
+ self['u_CT'] = var
182
+
183
+ var = self['u_CROSS'].clone()
184
+ var.name = 'u_VCT'
185
+ var.label = r'$u_{VCT}$'
186
+ var.visual.axis[1].lim = [None, None]
187
+ var.value = u_VCT[:, np.newaxis]
188
+ self['u_VCT'] = var
134
189
 
135
190
  def convert_to_APEX(self):
136
191
  import geospacelab.cs as gsl_cs
@@ -199,7 +254,9 @@ class Dataset(datahub.DatasetSourced):
199
254
  file_patterns = [
200
255
  'CH',
201
256
  self.product.upper().replace('-', '_'),
202
- this_day.strftime('%Y_%m'),
257
+ this_day.strftime('%Y'),
258
+ this_day.strftime('%m'),
259
+ self.product_version,
203
260
  ]
204
261
  # remove empty str
205
262
  file_patterns = [pattern for pattern in file_patterns if str(pattern)]
@@ -221,7 +278,7 @@ class Dataset(datahub.DatasetSourced):
221
278
  search_pattern=search_pattern,
222
279
  allow_multiple_files=False
223
280
  )
224
-
281
+ self.data_file_paths = np.unique(self.data_file_paths)
225
282
  return done
226
283
 
227
284
  def download_data(self, dt_fr=None, dt_to=None):
@@ -233,10 +290,11 @@ class Dataset(datahub.DatasetSourced):
233
290
  dt_fr, dt_to,
234
291
  product=self.product,
235
292
  version=self.product_version,
236
- force=self.force_download
293
+ force_download=self.force_download,
294
+ dry_run=self.download_dry_run
237
295
  )
238
296
 
239
- return download_obj.done
297
+ return any(download_obj.done)
240
298
 
241
299
  @property
242
300
  def database(self):
@@ -8,42 +8,35 @@ __license__ = "BSD-3-Clause License"
8
8
  __email__ = "lei.cai@oulu.fi"
9
9
  __docformat__ = "reStructureText"
10
10
 
11
+ import datetime
11
12
  from geospacelab.config import prf
12
13
 
13
- from geospacelab.datahub.sources.tud.downloader import Downloader as DownloaderModel
14
-
15
-
16
- class Downloader(DownloaderModel):
17
-
18
- def __init__(
19
- self, dt_fr, dt_to,
20
- product='WND-ACC',
21
- version='v01',
22
- force=True, direct_download=True, **kwargs
23
- ):
24
- if version == 'v01':
25
- v_str = "version_01"
26
- elif version == 'v02':
27
- raise NotImplementedError
28
- else:
29
- raise NotImplementedError
30
- data_file_root_dir = prf.datahub_data_root_dir / "TUD" / "CHAMP" / product.upper() / version
31
- ftp_data_dir = f'{v_str}/CHAMP_data'
32
- file_name_patterns = ['CH', product.replace('-', '_')]
33
- super(Downloader, self).__init__(
34
- dt_fr, dt_to,
35
- data_file_root_dir=data_file_root_dir, ftp_data_dir=ftp_data_dir, force=force,
36
- direct_download=direct_download, file_name_patterns=file_name_patterns, **kwargs
14
+ from geospacelab.datahub.sources.tud.downloader import TUDownloader as DownloaderBase
15
+
16
+
17
+ class Downloader(DownloaderBase):
18
+
19
+ def __init__(self,
20
+ dt_fr, dt_to,
21
+ mission='CHAMP',
22
+ sat_id='',
23
+ version='v02',
24
+ product='WND-ACC',
25
+ direct_download=True,
26
+ force_download=False,
27
+ dry_run=False,
28
+ ):
29
+ self.mission = mission
30
+ self.version = version
31
+
32
+ super().__init__(
33
+ dt_fr, dt_to,
34
+ mission=mission,
35
+ sat_id=sat_id,
36
+ version=version,
37
+ product=product,
38
+ direct_download=direct_download,
39
+ force_download=force_download,
40
+ dry_run=dry_run
37
41
  )
38
-
39
- def download(self, **kwargs):
40
-
41
- done = super(Downloader, self).download(**kwargs)
42
- return done
43
-
44
- def search_files(self, **kwargs):
45
-
46
- file_list = super(Downloader, self).search_files(**kwargs)
47
-
48
- return file_list
49
- # version control
42
+
@@ -30,7 +30,7 @@ class Loader(object):
30
30
  if self.version == 'v01':
31
31
  self.load_v01()
32
32
  elif self.version == 'v02':
33
- raise NotImplementedError
33
+ self.load_v02()
34
34
  else:
35
35
  raise NotImplementedError
36
36
 
@@ -59,10 +59,39 @@ class Loader(object):
59
59
  self.variables['SC_ARG_LAT'] = np.array(results[6]).astype(np.float32).reshape(num_rec, 1)
60
60
  self.variables['u_CROSS_E'] = np.array(results[7]).astype(np.float32).reshape(num_rec, 1)
61
61
  self.variables['u_CROSS_N'] = np.array(results[8]).astype(np.float32).reshape(num_rec, 1)
62
- self.variables['u_CROSS_U'] = np.array(results[9]).astype(np.float32).reshape(num_rec, 1)
62
+ self.variables['u_CROSS'] = - np.array(results[9]).astype(np.float32).reshape(num_rec, 1)
63
+ self.variables['u_CROSS_D'] = np.zeros_like(self.variables['u_CROSS'])
64
+
65
+ self.variables['UNIT_VECTOR_N'] = self.variables['u_CROSS_N'] / self.variables['u_CROSS']
66
+ self.variables['UNIT_VECTOR_E'] = self.variables['u_CROSS_E'] / self.variables['u_CROSS']
67
+ self.variables['UNIT_VECTOR_D'] = self.variables['u_CROSS_D'] / self.variables['u_CROSS']
63
68
 
64
- self.variables['u_CROSS'] = np.sqrt(
65
- self.variables['u_CROSS_E']**2
66
- + self.variables['u_CROSS_N']**2
67
- + self.variables['u_CROSS_U']**2
68
- )
69
+ def load_v02(self):
70
+ with open(self.file_path, 'r') as f:
71
+ text = f.read()
72
+ results = re.findall(
73
+ r"^(\d{4}-\d{2}-\d{2}\s*\d{2}\:\d{2}\:\d{2}\.\d{3})\s*(\w{3})\s*"
74
+ + r"([\-\d.]+)\s*([\-\d.]+)\s*([\-\d.]+)\s*([\-\d.]+)\s*([\-\d.]+)\s*"
75
+ + r"([\-\d.]+)\s*([\-\d.]+)\s*([\-\d.]+)\s*([\-\d.]+)\s*([\-\d.]+)",
76
+ text,
77
+ re.M)
78
+ results = list(zip(*results))
79
+ dts = [datetime.datetime.strptime(dtstr + '000', "%Y-%m-%d %H:%M:%S.%f") for dtstr in results[0]]
80
+ if results[1][0] == 'GPS':
81
+ t_gps = [(dt - dttool._GPS_DATETIME_0).total_seconds() for dt in dts]
82
+ dts = dttool.convert_gps_time_to_datetime(t_gps, weeks=None)
83
+ num_rec = len(dts)
84
+ self.variables['SC_DATETIME'] = np.array(dts).reshape(num_rec, 1)
85
+ self.variables['SC_GEO_ALT'] = np.array(results[2]).astype(np.float32).reshape(num_rec, 1) * 1e-3 # in km
86
+ self.variables['SC_GEO_LON'] = np.array(results[3]).astype(np.float32).reshape(num_rec, 1)
87
+ self.variables['SC_GEO_LAT'] = np.array(results[4]).astype(np.float32).reshape(num_rec, 1)
88
+ self.variables['SC_GEO_LST'] = np.array(results[5]).astype(np.float32).reshape(num_rec, 1)
89
+ self.variables['SC_ARG_LAT'] = np.array(results[6]).astype(np.float32).reshape(num_rec, 1)
90
+ self.variables['u_CROSS'] = np.array(results[7]).astype(np.float32).reshape(num_rec, 1)
91
+ self.variables['UNIT_VECTOR_N'] = np.array(results[8]).astype(np.float32).reshape(num_rec, 1)
92
+ self.variables['UNIT_VECTOR_E'] = np.array(results[9]).astype(np.float32).reshape(num_rec, 1)
93
+ self.variables['UNIT_VECTOR_D'] = np.array(results[10]).astype(np.float32).reshape(num_rec, 1)
94
+ self.variables['FLAG'] = np.array(results[6]).astype(np.float32).reshape(num_rec, 1)
95
+ self.variables['u_CROSS_E'] = self.variables['u_CROSS'] * self.variables['UNIT_VECTOR_E']
96
+ self.variables['u_CROSS_N'] = self.variables['u_CROSS'] * self.variables['UNIT_VECTOR_N']
97
+ self.variables['u_CROSS_D'] = self.variables['u_CROSS'] * self.variables['UNIT_VECTOR_D']
@@ -116,11 +116,11 @@ axis[1].unit = '@v.unit_label'
116
116
  configured_variables[var_name] = var
117
117
 
118
118
  ####################################################################################################################
119
- var_name = 'u_CROSS_U'
119
+ var_name = 'u_CROSS_D'
120
120
  var = Var(name=var_name, ndim=1, variable_type='scalar', visual=visual)
121
121
  # set variable attrs
122
- var.fullname = 'Cross neutral wind (Upward)'
123
- var.label = r'$u_{Up}$'
122
+ var.fullname = 'Cross neutral wind (Downward)'
123
+ var.label = r'$u_{Down}$'
124
124
  var.unit = 'm/s'
125
125
  var.unit_label = r'm/s'
126
126
  var.group = r'$u$'