maser-data 0.1.1__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.
- maser.data-0.1.1/PKG-INFO +22 -0
- maser.data-0.1.1/maser/__init__.py +2 -0
- maser.data-0.1.1/maser/data/__init__.py +52 -0
- maser.data-0.1.1/maser/data/base/__init__.py +36 -0
- maser.data-0.1.1/maser/data/base/base.py +268 -0
- maser.data-0.1.1/maser/data/base/dataset_filename_regex.json +18 -0
- maser.data-0.1.1/maser/data/base/mixins.py +74 -0
- maser.data-0.1.1/maser/data/base/records.py +43 -0
- maser.data-0.1.1/maser/data/base/sweeps.py +19 -0
- maser.data-0.1.1/maser/data/cdpp/__init__.py +34 -0
- maser.data-0.1.1/maser/data/cdpp/ccsds.py +319 -0
- maser.data-0.1.1/maser/data/cdpp/const.py +54 -0
- maser.data-0.1.1/maser/data/cdpp/interball/__init__.py +10 -0
- maser.data-0.1.1/maser/data/cdpp/interball/data.py +176 -0
- maser.data-0.1.1/maser/data/cdpp/interball/records.py +30 -0
- maser.data-0.1.1/maser/data/cdpp/interball/sweeps.py +31 -0
- maser.data-0.1.1/maser/data/cdpp/utils.py +23 -0
- maser.data-0.1.1/maser/data/cdpp/viking/__init__.py +3 -0
- maser.data-0.1.1/maser/data/cdpp/viking/const.py +190 -0
- maser.data-0.1.1/maser/data/cdpp/viking/data.py +40 -0
- maser.data-0.1.1/maser/data/cdpp/viking/records.py +581 -0
- maser.data-0.1.1/maser/data/cdpp/wind/__init__.py +22 -0
- maser.data-0.1.1/maser/data/cdpp/wind/data.py +331 -0
- maser.data-0.1.1/maser/data/cdpp/wind/records.py +95 -0
- maser.data-0.1.1/maser/data/cdpp/wind/sweeps.py +105 -0
- maser.data-0.1.1/maser/data/ecallisto/__init__.py +27 -0
- maser.data-0.1.1/maser/data/ecallisto/data.py +28 -0
- maser.data-0.1.1/maser/data/nancay/__init__.py +37 -0
- maser.data-0.1.1/maser/data/nancay/nda/__init__.py +7 -0
- maser.data-0.1.1/maser/data/nancay/nda/data.py +28 -0
- maser.data-0.1.1/maser/data/nancay/nda/sweeps.py +30 -0
- maser.data-0.1.1/maser/data/nancay/nenufar/__init__.py +7 -0
- maser.data-0.1.1/maser/data/nancay/nenufar/data.py +53 -0
- maser.data-0.1.1/maser/data/padc/__init__.py +9 -0
- maser.data-0.1.1/maser/data/padc/cassini/__init__.py +5 -0
- maser.data-0.1.1/maser/data/padc/cassini/data.py +206 -0
- maser.data-0.1.1/maser/data/padc/cassini/kronos.py +221 -0
- maser.data-0.1.1/maser/data/padc/cassini/kronos_level_format.json +223 -0
- maser.data-0.1.1/maser/data/padc/juno/__init__.py +4 -0
- maser.data-0.1.1/maser/data/padc/juno/data.py +52 -0
- maser.data-0.1.1/maser/data/pds/__init__.py +15 -0
- maser.data-0.1.1/maser/data/pds/co/__init__.py +5 -0
- maser.data-0.1.1/maser/data/pds/co/data.py +22 -0
- maser.data-0.1.1/maser/data/pds/data.py +88 -0
- maser.data-0.1.1/maser/data/pds/utils.py +450 -0
- maser.data-0.1.1/maser/data/pds/vg/__init__.py +8 -0
- maser.data-0.1.1/maser/data/pds/vg/data.py +32 -0
- maser.data-0.1.1/maser/data/psa/__init__.py +11 -0
- maser.data-0.1.1/maser/data/psa/labels/MEX-M-MARSIS-3-RDR-AIS-V1.0/AIS_FORMAT.FMT +184 -0
- maser.data-0.1.1/maser/data/psa/labels/__init__.py +10 -0
- maser.data-0.1.1/maser/data/psa/mex/__init__.py +11 -0
- maser.data-0.1.1/maser/data/psa/mex/consts.py +31 -0
- maser.data-0.1.1/maser/data/psa/mex/data.py +194 -0
- maser.data-0.1.1/maser/data/rpw/__init__.py +3 -0
- maser.data-0.1.1/maser/data/rpw/lfr.py +125 -0
- maser.data-0.1.1/maser/data/rpw/tnr.py +140 -0
- maser.data-0.1.1/maser/data/rpw/tnr_filter.py +79 -0
- maser.data-0.1.1/maser/data/sweep.py +4 -0
- maser.data-0.1.1/pyproject.toml +30 -0
- maser.data-0.1.1/setup.py +60 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: maser.data
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary:
|
|
5
|
+
License: CeCILL
|
|
6
|
+
Author: Baptiste Cecconi
|
|
7
|
+
Author-email: baptiste.cecconi@obspm.fr
|
|
8
|
+
Requires-Python: >=3.8,<4
|
|
9
|
+
Classifier: License :: Other/Proprietary License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
13
|
+
Provides-Extra: all
|
|
14
|
+
Provides-Extra: jupyter
|
|
15
|
+
Provides-Extra: nenupy
|
|
16
|
+
Provides-Extra: spacepy
|
|
17
|
+
Requires-Dist: astropy (>=5.0.4,<6.0.0)
|
|
18
|
+
Requires-Dist: jupyter (>=1.0.0,<2.0.0); extra == "jupyter" or extra == "all"
|
|
19
|
+
Requires-Dist: jupytext (>=1.13.8,<2.0.0); extra == "jupyter" or extra == "all"
|
|
20
|
+
Requires-Dist: nenupy (>=2.1.0,<3.0.0); extra == "nenupy" or extra == "all"
|
|
21
|
+
Requires-Dist: spacepy (>=0.3.0,<0.4.0); extra == "spacepy" or extra == "all"
|
|
22
|
+
Requires-Dist: xarray (>=2022.3.0,<2023.0.0)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from .base import Data
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from .cdpp import ( # noqa: F401
|
|
6
|
+
WindWavesRad1L260sV2BinData,
|
|
7
|
+
WindWavesRad1L2BinData,
|
|
8
|
+
WindWavesRad2L260sV2BinData,
|
|
9
|
+
WindWavesTnrL260sV2BinData,
|
|
10
|
+
WindWavesTnrL3Bqt1mnBinData,
|
|
11
|
+
WindWavesTnrL3NnBinData,
|
|
12
|
+
WindWavesRad1L260sV1BinData,
|
|
13
|
+
WindWavesRad2L260sV1BinData,
|
|
14
|
+
WindWavesTnrL260sV1BinData,
|
|
15
|
+
VikingV4nE5BinData,
|
|
16
|
+
InterballAuroralPolradRspBinData,
|
|
17
|
+
)
|
|
18
|
+
from .ecallisto import ( # noqa: F401
|
|
19
|
+
ECallistoFitsData,
|
|
20
|
+
)
|
|
21
|
+
from .nancay import ( # noqa: F401
|
|
22
|
+
SrnNdaRoutineJupEdrCdfData,
|
|
23
|
+
NenufarBstFitsData,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
# -*- coding: utf-8 -*-
|
|
27
|
+
from .padc import ( # noqa: F401
|
|
28
|
+
JnoWavLesiaL3aV02Data,
|
|
29
|
+
CoRpwsHfrKronosN1Data,
|
|
30
|
+
CoRpwsHfrKronosN2Data,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
from .pds import ( # noqa: F401
|
|
34
|
+
Pds3Data,
|
|
35
|
+
Vg1JPra3RdrLowband6secV1Data,
|
|
36
|
+
Vg1JPra4SummBrowse48secV1Data,
|
|
37
|
+
Vg1SPra3RdrLowband6secV1Data,
|
|
38
|
+
Vg2NPra2RdrHighrate60msV1Data,
|
|
39
|
+
Vg2NPra3RdrLowband6secV1Data,
|
|
40
|
+
CoVEJSSSRpws2RefdrWbrFullV1Data,
|
|
41
|
+
CoVEJSSSRpws3RdrLrFullV1Data,
|
|
42
|
+
)
|
|
43
|
+
from .psa import MexMMarsis3RdrAisExt4V1Data # noqa: F401
|
|
44
|
+
|
|
45
|
+
from .rpw import ( # noqa: F401
|
|
46
|
+
RpwLfrSurvBp1,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
if __name__ == "__main__":
|
|
51
|
+
data = Data(filepath=Path("toto.txt"), dataset="cdf")
|
|
52
|
+
print(type(data))
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Base Classes for MASER-Data
|
|
5
|
+
===========================
|
|
6
|
+
|
|
7
|
+
Data object classes
|
|
8
|
+
-------------------
|
|
9
|
+
|
|
10
|
+
* `Data` Class: The `Data` class is the base class to be used to load data with the MASER-Data module.
|
|
11
|
+
* `BinData` Class: Generic class for custom binary formatted data products.
|
|
12
|
+
* `CdfData` Class: Generic class for CDF formatted data products.
|
|
13
|
+
* `FitsData` Class: Generic class for FITS formatted data products.
|
|
14
|
+
|
|
15
|
+
Iterator classes
|
|
16
|
+
----------------
|
|
17
|
+
|
|
18
|
+
* `Sweeps` Class: Generic iterator class for sweep-based access.
|
|
19
|
+
* `Records` Class: Generic iterator class for record-based access.
|
|
20
|
+
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
from .base import ( # noqa: F401
|
|
25
|
+
Data,
|
|
26
|
+
BinData,
|
|
27
|
+
CdfData,
|
|
28
|
+
FitsData,
|
|
29
|
+
)
|
|
30
|
+
from .mixins import ( # noqa: F401
|
|
31
|
+
RecordsOnly,
|
|
32
|
+
FixedFrequencies,
|
|
33
|
+
VariableFrequencies,
|
|
34
|
+
)
|
|
35
|
+
from .sweeps import Sweeps # noqa: F401
|
|
36
|
+
from .records import Records # noqa: F401
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from typing import Union, Dict, Type, cast, Optional
|
|
3
|
+
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
import re
|
|
6
|
+
from astropy.io import fits
|
|
7
|
+
import numpy
|
|
8
|
+
from .sweeps import Sweeps
|
|
9
|
+
from .records import Records
|
|
10
|
+
|
|
11
|
+
from astropy.time import Time
|
|
12
|
+
from astropy.units import Quantity
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class BaseData:
|
|
16
|
+
"""Base class for all data classes."""
|
|
17
|
+
|
|
18
|
+
dataset: str
|
|
19
|
+
_registry: Dict[str, Type["BaseData"]] = {}
|
|
20
|
+
_access_modes = ["sweeps", "records", "file"]
|
|
21
|
+
_iter_sweep_class = Sweeps
|
|
22
|
+
_iter_record_class = Records
|
|
23
|
+
|
|
24
|
+
def __init_subclass__(cls, *args, dataset: str, **kwargs) -> None:
|
|
25
|
+
"""Register subclasses to be able to instantiate them using only the dataset name
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
cls (BaseData): Subclass of BaseData
|
|
29
|
+
dataset (str): Dataset name
|
|
30
|
+
"""
|
|
31
|
+
# store the dataset name in the class
|
|
32
|
+
cls.dataset = dataset
|
|
33
|
+
|
|
34
|
+
# add the subclass to the BaseData registry
|
|
35
|
+
BaseData._registry[dataset] = cls
|
|
36
|
+
|
|
37
|
+
def __init__(
|
|
38
|
+
self,
|
|
39
|
+
filepath: Path,
|
|
40
|
+
dataset: Union[None, str] = "__auto__",
|
|
41
|
+
access_mode: str = "sweeps",
|
|
42
|
+
load_data: bool = True,
|
|
43
|
+
fixed_frequencies: bool = True,
|
|
44
|
+
) -> None:
|
|
45
|
+
|
|
46
|
+
# store the filepath as a Path object
|
|
47
|
+
self.filepath = Path(filepath)
|
|
48
|
+
|
|
49
|
+
# check if access_mode is valid
|
|
50
|
+
if access_mode not in self._access_modes:
|
|
51
|
+
raise ValueError("Illegal access mode.")
|
|
52
|
+
else:
|
|
53
|
+
self.access_mode = access_mode
|
|
54
|
+
|
|
55
|
+
# a reference to the file object
|
|
56
|
+
self._file = None
|
|
57
|
+
|
|
58
|
+
# store the computed times/frequencies to avoid computing them again
|
|
59
|
+
self._times = None
|
|
60
|
+
self._frequencies = None
|
|
61
|
+
|
|
62
|
+
# flag used to determine if are in lazy mode or not
|
|
63
|
+
self._load_data = load_data
|
|
64
|
+
|
|
65
|
+
self.fixed_frequencies = fixed_frequencies
|
|
66
|
+
|
|
67
|
+
@property
|
|
68
|
+
def load_data(self) -> bool:
|
|
69
|
+
return self._load_data
|
|
70
|
+
|
|
71
|
+
@classmethod
|
|
72
|
+
def get_dataset(cls, filepath):
|
|
73
|
+
pass
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class Data(BaseData, dataset="default"):
|
|
77
|
+
"""Generic Data class
|
|
78
|
+
=====================
|
|
79
|
+
|
|
80
|
+
Objects of this class are instanciated from a data file. An internal resolver will detect the
|
|
81
|
+
dataset and provide adequate support. If the file is not recognized, an NotImplementedError is
|
|
82
|
+
raised.
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
"""
|
|
86
|
+
|
|
87
|
+
def __new__(
|
|
88
|
+
cls, filepath: Path, dataset: Union[None, str] = "__auto__", *args, **kwargs
|
|
89
|
+
) -> "Data":
|
|
90
|
+
if dataset is None:
|
|
91
|
+
# call the base data class __new__ method
|
|
92
|
+
return super().__new__(cls)
|
|
93
|
+
elif dataset == "__auto__":
|
|
94
|
+
# try to guess the dataset
|
|
95
|
+
dataset = cls.get_dataset(cls, filepath)
|
|
96
|
+
|
|
97
|
+
# get the dataset class from the registry
|
|
98
|
+
# we need an explicit cast to make mypy happy
|
|
99
|
+
dataset_class = BaseData._registry[cast(str, dataset)]
|
|
100
|
+
|
|
101
|
+
# create a new instance of the dataset class
|
|
102
|
+
# ignore 'gets multiple values for keyword argument "dataset"'
|
|
103
|
+
return dataset_class(filepath, dataset=None, *args, **kwargs) # type: ignore
|
|
104
|
+
else:
|
|
105
|
+
# get the dataset class from the registry
|
|
106
|
+
dataset_class = BaseData._registry[cast(str, dataset)]
|
|
107
|
+
|
|
108
|
+
# create a new instance of the dataset class
|
|
109
|
+
# ignore 'gets multiple values for keyword argument "dataset"'
|
|
110
|
+
return dataset_class(filepath, dataset=None, *args, **kwargs) # type: ignore
|
|
111
|
+
|
|
112
|
+
@classmethod
|
|
113
|
+
def open(cls, filepath: Path, *args, **kwargs):
|
|
114
|
+
"""Generic open() method."""
|
|
115
|
+
return open(filepath, *args, **kwargs)
|
|
116
|
+
|
|
117
|
+
@classmethod
|
|
118
|
+
def close(cls, file):
|
|
119
|
+
"""Generic close() method."""
|
|
120
|
+
file.close()
|
|
121
|
+
|
|
122
|
+
@property
|
|
123
|
+
def file(self):
|
|
124
|
+
"""Generic open method (using the default open class)."""
|
|
125
|
+
if not self._file:
|
|
126
|
+
self._file = self.open(self.filepath)
|
|
127
|
+
return self._file
|
|
128
|
+
|
|
129
|
+
@property
|
|
130
|
+
def sweeps(self):
|
|
131
|
+
"""Generic iterator method to access sweeps."""
|
|
132
|
+
for sweep in self._iter_sweep_class(data_instance=self):
|
|
133
|
+
yield sweep
|
|
134
|
+
|
|
135
|
+
@property
|
|
136
|
+
def records(self):
|
|
137
|
+
"""Generic iterator method to access records."""
|
|
138
|
+
for record in self._iter_record_class(data_instance=self):
|
|
139
|
+
yield record
|
|
140
|
+
|
|
141
|
+
@property
|
|
142
|
+
def meta(self) -> dict:
|
|
143
|
+
"""Generic method to metadata."""
|
|
144
|
+
return dict()
|
|
145
|
+
|
|
146
|
+
@property
|
|
147
|
+
def times(self) -> Optional[Time]:
|
|
148
|
+
"""Generic method to get the time axis."""
|
|
149
|
+
return None
|
|
150
|
+
|
|
151
|
+
@property
|
|
152
|
+
def frequencies(self) -> Union[Quantity, Dict, None]:
|
|
153
|
+
"""Generic method to get the spectral axis."""
|
|
154
|
+
return None
|
|
155
|
+
|
|
156
|
+
def as_array(self) -> numpy.ndarray:
|
|
157
|
+
"""Generic method to get the data as a numpy.array."""
|
|
158
|
+
pass
|
|
159
|
+
|
|
160
|
+
def as_xarray(self) -> dict:
|
|
161
|
+
"""Generic method to get the data as a dict with xarray.DataArray values"""
|
|
162
|
+
pass
|
|
163
|
+
|
|
164
|
+
def __enter__(self):
|
|
165
|
+
if self.access_mode == "file":
|
|
166
|
+
return self.file
|
|
167
|
+
else:
|
|
168
|
+
return self
|
|
169
|
+
|
|
170
|
+
def __exit__(self, *args, **kwargs):
|
|
171
|
+
if self._file:
|
|
172
|
+
self.close(self._file)
|
|
173
|
+
|
|
174
|
+
@property
|
|
175
|
+
def file_size(self):
|
|
176
|
+
import os
|
|
177
|
+
|
|
178
|
+
return os.path.getsize(self.filepath)
|
|
179
|
+
|
|
180
|
+
def __iter__(self):
|
|
181
|
+
# get the reference to the right iterator (file, sweeps or records)
|
|
182
|
+
ref = getattr(self, self.access_mode)
|
|
183
|
+
print(ref)
|
|
184
|
+
for item in ref:
|
|
185
|
+
yield item
|
|
186
|
+
|
|
187
|
+
@staticmethod
|
|
188
|
+
def get_dataset(cls, filepath):
|
|
189
|
+
"""Dataset selector method.
|
|
190
|
+
|
|
191
|
+
This method identifies CdfData, FitsData and Pds3Data.
|
|
192
|
+
Other datasets are treated as BinData.
|
|
193
|
+
"""
|
|
194
|
+
filepath = Path(filepath)
|
|
195
|
+
if filepath.suffix.lower() == ".cdf":
|
|
196
|
+
dataset = BaseData._registry["cdf"].get_dataset(filepath)
|
|
197
|
+
elif filepath.suffix.lower() in [".fits", ".fit"]:
|
|
198
|
+
dataset = BaseData._registry["fits"].get_dataset(filepath)
|
|
199
|
+
elif filepath.suffix.lower() == ".lbl":
|
|
200
|
+
dataset = BaseData._registry["pds3"].get_dataset(filepath)
|
|
201
|
+
else:
|
|
202
|
+
dataset = BaseData._registry["bin"].get_dataset(filepath)
|
|
203
|
+
return dataset
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
class CdfData(Data, dataset="cdf"):
|
|
207
|
+
"""Base class for CDF formatted data. Requires `spacepy`."""
|
|
208
|
+
|
|
209
|
+
@classmethod
|
|
210
|
+
def open(cls, filepath: Path, *args, **kwargs):
|
|
211
|
+
"""Open method for CDF formatted data products"""
|
|
212
|
+
from spacepy import pycdf
|
|
213
|
+
|
|
214
|
+
return pycdf.CDF(str(filepath))
|
|
215
|
+
|
|
216
|
+
@classmethod
|
|
217
|
+
def get_dataset(cls, filepath):
|
|
218
|
+
"""Dataset selector for CDF files (must be ISTP compliant)"""
|
|
219
|
+
with cls.open(filepath) as c:
|
|
220
|
+
dataset = c.attrs["Logical_source"][...][0]
|
|
221
|
+
return dataset
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
class FitsData(Data, dataset="fits"):
|
|
225
|
+
"""Base class for FITS formatted data. FITS formatted NenuFAR data requires `nenupy`."""
|
|
226
|
+
|
|
227
|
+
@classmethod
|
|
228
|
+
def open(cls, filepath: Path, *args, **kwargs):
|
|
229
|
+
"""Open method for FITS formatted data products"""
|
|
230
|
+
return fits.open(filepath, *args, **kwargs)
|
|
231
|
+
|
|
232
|
+
@classmethod
|
|
233
|
+
def get_dataset(cls, filepath):
|
|
234
|
+
"""Dataset selector for FITS files"""
|
|
235
|
+
with cls.open(filepath) as f:
|
|
236
|
+
if f[0].header["INSTRUME"] == "NenuFar" and filepath.stem.endswith("_BST"):
|
|
237
|
+
dataset = "srn_nenufar_bst"
|
|
238
|
+
elif "e-CALLISTO" in f[0].header["CONTENT"]:
|
|
239
|
+
dataset = "ecallisto"
|
|
240
|
+
return dataset
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
class BinData(Data, dataset="bin"):
|
|
244
|
+
"""Base class for custom binary data."""
|
|
245
|
+
|
|
246
|
+
@classmethod
|
|
247
|
+
def open(cls, filepath: Path, *args, mode: str = "rb", **kwargs):
|
|
248
|
+
# ignore 'No overload variant of "open" ...'
|
|
249
|
+
return filepath.open(*args, mode=mode, **kwargs) # type: ignore
|
|
250
|
+
|
|
251
|
+
@classmethod
|
|
252
|
+
def get_dataset(cls, filepath):
|
|
253
|
+
"""Dataset selector for Binary files.
|
|
254
|
+
|
|
255
|
+
If the dataset is not recognized, a NotImplementedError is raised.
|
|
256
|
+
"""
|
|
257
|
+
filepath = Path(filepath)
|
|
258
|
+
|
|
259
|
+
import json
|
|
260
|
+
|
|
261
|
+
with open(Path(__file__).parent / "dataset_filename_regex.json") as f:
|
|
262
|
+
filename_regex = json.load(f)
|
|
263
|
+
|
|
264
|
+
for dataset, regex in filename_regex["bin"]:
|
|
265
|
+
if re.match(regex, filepath.name) is not None:
|
|
266
|
+
return dataset
|
|
267
|
+
else:
|
|
268
|
+
raise NotImplementedError()
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"bin": [
|
|
3
|
+
["cdpp_wi_wa_rad1_l2", "^wi_wa_rad1_l2_\\d{8}_v\\d{2}.dat$"],
|
|
4
|
+
["cdpp_wi_wa_rad1_l2_60s_v2", "^wi_wa_rad1_l2_60s_\\d{8}_v\\d{2}.dat$"],
|
|
5
|
+
["cdpp_wi_wa_rad2_l2", "^wi_wa_rad2_l2_\\d{8}_v\\d{2}.dat$"],
|
|
6
|
+
["cdpp_wi_wa_rad2_l2_60s_v2", "^wi_wa_rad2_l2_60s_\\d{8}_v\\d{2}.dat$"],
|
|
7
|
+
["cdpp_wi_wa_tnr_l2_60s_v2", "^wi_wa_tnr_l2_60s_\\d{8}_v\\d{2}.dat$"],
|
|
8
|
+
["cdpp_wi_wa_tnr_l3_bqt_1mn", "^WI_WA_TNR_L3_BQT_\\d{8}_1MN.DAT$"],
|
|
9
|
+
["cdpp_wi_wa_tnr_l3_nn", "^WI_WA_TNR_L3_NN_\\d{8}_V\\d{2}.DAT$"],
|
|
10
|
+
["cdpp_wi_wa_rad1_l2_60s_v1", "^WIN_RAD1_60S_\\d{8}.B3E$"],
|
|
11
|
+
["cdpp_wi_wa_rad2_l2_60s_v1", "^WIN_RAD2_60S_\\d{8}.B3E$"],
|
|
12
|
+
["cdpp_wi_wa_tnr_l2_60s_v1", "^WIN_TNR_60S_\\d{8}.B3E$"],
|
|
13
|
+
["cdpp_viking_v4n_e5", "^V4N_\\d{4}_\\d{3}$"],
|
|
14
|
+
["cdpp_int_aur_polrad_rspn2", "^POLR_RSPN2_\\d{8}$"],
|
|
15
|
+
["co_rpws_hfr_kronos_n1", "^R\\d{7}\\.\\d{2}$"],
|
|
16
|
+
["co_rpws_hfr_kronos_n2", "^P\\d{7}\\.\\d{2}$"]
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
import numpy
|
|
4
|
+
from typing import Union
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class RecordsOnly:
|
|
8
|
+
_access_modes = ["records", "file"]
|
|
9
|
+
|
|
10
|
+
@property
|
|
11
|
+
def sweeps(self):
|
|
12
|
+
raise ValueError("Illegal access mode.")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class FixedFrequencies:
|
|
16
|
+
pass
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class VariableFrequencies:
|
|
20
|
+
def __init__(self):
|
|
21
|
+
self.fixed_frequencies = False
|
|
22
|
+
self._sweep_masks = None
|
|
23
|
+
self._sweep_mode_masks = None
|
|
24
|
+
self.__frequencies = None
|
|
25
|
+
self.__max_sweep_length = None
|
|
26
|
+
|
|
27
|
+
@property
|
|
28
|
+
def sweep_masks(self) -> Union[list, None]:
|
|
29
|
+
return None
|
|
30
|
+
|
|
31
|
+
@property
|
|
32
|
+
def sweep_mode_masks(self) -> Union[list, None]:
|
|
33
|
+
return None
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
def _max_sweep_length(self):
|
|
37
|
+
if self.__max_sweep_length is None:
|
|
38
|
+
self.__max_sweep_length = numpy.max([len(f) for f in self.frequencies])
|
|
39
|
+
return self.__max_sweep_length
|
|
40
|
+
|
|
41
|
+
def as_xarray(self):
|
|
42
|
+
import xarray
|
|
43
|
+
|
|
44
|
+
fields = self.fields
|
|
45
|
+
units = self.units
|
|
46
|
+
|
|
47
|
+
freq_arr = numpy.full((self._nsweep, self._max_sweep_length), numpy.nan)
|
|
48
|
+
for i in range(self._nsweep):
|
|
49
|
+
f = self.frequencies[i].value
|
|
50
|
+
freq_arr[i, : len(f)] = f
|
|
51
|
+
freq_arr[i, len(f) :] = f[-1]
|
|
52
|
+
|
|
53
|
+
freq_index = range(self._max_sweep_length)
|
|
54
|
+
|
|
55
|
+
datasets = {}
|
|
56
|
+
for dataset_key, dataset_unit in zip(fields, units):
|
|
57
|
+
data_arr = numpy.full((self._nsweep, self._max_sweep_length), numpy.nan)
|
|
58
|
+
for i, sweep in enumerate(self.sweeps):
|
|
59
|
+
d = sweep.data[dataset_key]
|
|
60
|
+
data_arr[i, : len(d)] = d
|
|
61
|
+
|
|
62
|
+
datasets[dataset_key] = xarray.DataArray(
|
|
63
|
+
data=data_arr,
|
|
64
|
+
name=dataset_key,
|
|
65
|
+
coords={
|
|
66
|
+
"freq_index": freq_index,
|
|
67
|
+
"time": self.times.to_datetime(),
|
|
68
|
+
"frequency": (["time", "freq_index"], freq_arr, {"units": "kHz"}),
|
|
69
|
+
},
|
|
70
|
+
attrs={"units": dataset_unit},
|
|
71
|
+
dims=("time", "freq_index"),
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
return datasets
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
class Record:
|
|
3
|
+
def __init__(self, header, data):
|
|
4
|
+
self.header = header
|
|
5
|
+
self.data = data
|
|
6
|
+
self._time = None
|
|
7
|
+
|
|
8
|
+
@property
|
|
9
|
+
def time(self):
|
|
10
|
+
return self._time
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Records:
|
|
14
|
+
def __init__(self, *, data_instance):
|
|
15
|
+
"""_summary_
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
data_instance (maser.data.Data): a reference to the parent data object
|
|
19
|
+
"""
|
|
20
|
+
self.data_reference = data_instance
|
|
21
|
+
|
|
22
|
+
def __iter__(self):
|
|
23
|
+
for d in self.generator:
|
|
24
|
+
yield d
|
|
25
|
+
|
|
26
|
+
def __call__(self, load_data: bool = None, *args, **kwargs):
|
|
27
|
+
return self.generator
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
def load_data(self):
|
|
31
|
+
return self.data_reference.load_data
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def file(self):
|
|
35
|
+
return self.data_reference.file
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def generator(self):
|
|
39
|
+
for d in self.file:
|
|
40
|
+
yield d
|
|
41
|
+
|
|
42
|
+
def __next__(self):
|
|
43
|
+
next(self.generator)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from .records import Records, Record
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Sweep(Record):
|
|
6
|
+
def __init__(self, header, data):
|
|
7
|
+
super().__init__(header, data)
|
|
8
|
+
self._frequencies = None
|
|
9
|
+
|
|
10
|
+
@property
|
|
11
|
+
def frequencies(self):
|
|
12
|
+
return self._frequencies
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Sweeps(Records):
|
|
16
|
+
@property
|
|
17
|
+
def generator(self):
|
|
18
|
+
for sweep in self.data_reference._data:
|
|
19
|
+
yield sweep
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from .wind import ( # noqa: F401
|
|
3
|
+
WindWavesRad1L260sV2BinData,
|
|
4
|
+
WindWavesRad1L260sV1BinData,
|
|
5
|
+
WindWavesRad2L260sV1BinData,
|
|
6
|
+
WindWavesTnrL260sV1BinData,
|
|
7
|
+
WindWavesRad1L2BinData,
|
|
8
|
+
WindWavesTnrL3NnBinData,
|
|
9
|
+
WindWavesTnrL260sV2BinData,
|
|
10
|
+
WindWavesRad2L260sV2BinData,
|
|
11
|
+
WindWavesTnrL3Bqt1mnBinData,
|
|
12
|
+
)
|
|
13
|
+
from .wind import ( # noqa: F401
|
|
14
|
+
WindWavesL260sSweeps,
|
|
15
|
+
WindWavesL2HighResSweeps,
|
|
16
|
+
WindWaves60sSweeps,
|
|
17
|
+
)
|
|
18
|
+
from .wind import ( # noqa: F401
|
|
19
|
+
WindWavesTnrL3Bqt1mnRecords,
|
|
20
|
+
)
|
|
21
|
+
from .viking import ( # noqa: F401
|
|
22
|
+
VikingV4nE5BinData,
|
|
23
|
+
)
|
|
24
|
+
from .interball import ( # noqa: F401
|
|
25
|
+
InterballAuroralPolradRspBinData,
|
|
26
|
+
)
|
|
27
|
+
from .interball import ( # noqa: F401
|
|
28
|
+
InterballAuroralPolradRspSweeps,
|
|
29
|
+
InterballAuroralPolradRspSweep,
|
|
30
|
+
)
|
|
31
|
+
from .interball import ( # noqa: F401
|
|
32
|
+
InterballAuroralPolradRspRecords,
|
|
33
|
+
InterballAuroralPolradRspRecord,
|
|
34
|
+
)
|