disdrodb 0.0.21__py3-none-any.whl → 0.1.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.
- disdrodb/__init__.py +132 -15
- disdrodb/_config.py +4 -2
- disdrodb/_version.py +9 -4
- disdrodb/api/checks.py +264 -237
- disdrodb/api/configs.py +4 -8
- disdrodb/api/create_directories.py +235 -290
- disdrodb/api/info.py +217 -26
- disdrodb/api/io.py +295 -269
- disdrodb/api/path.py +597 -173
- disdrodb/api/search.py +486 -0
- disdrodb/{metadata/scripts → cli}/disdrodb_check_metadata_archive.py +12 -7
- disdrodb/{utils/pandas.py → cli/disdrodb_data_archive_directory.py} +9 -18
- disdrodb/cli/disdrodb_download_archive.py +86 -0
- disdrodb/cli/disdrodb_download_metadata_archive.py +53 -0
- disdrodb/cli/disdrodb_download_station.py +84 -0
- disdrodb/{api/scripts → cli}/disdrodb_initialize_station.py +22 -10
- disdrodb/cli/disdrodb_metadata_archive_directory.py +32 -0
- disdrodb/{data_transfer/scripts/disdrodb_download_station.py → cli/disdrodb_open_data_archive.py} +22 -22
- disdrodb/cli/disdrodb_open_logs_directory.py +69 -0
- disdrodb/{data_transfer/scripts/disdrodb_upload_station.py → cli/disdrodb_open_metadata_archive.py} +22 -24
- disdrodb/cli/disdrodb_open_metadata_directory.py +71 -0
- disdrodb/cli/disdrodb_open_product_directory.py +74 -0
- disdrodb/cli/disdrodb_open_readers_directory.py +32 -0
- disdrodb/{l0/scripts → cli}/disdrodb_run_l0.py +38 -31
- disdrodb/{l0/scripts → cli}/disdrodb_run_l0_station.py +32 -30
- disdrodb/{l0/scripts → cli}/disdrodb_run_l0a.py +30 -21
- disdrodb/{l0/scripts → cli}/disdrodb_run_l0a_station.py +24 -33
- disdrodb/{l0/scripts → cli}/disdrodb_run_l0b.py +30 -21
- disdrodb/{l0/scripts → cli}/disdrodb_run_l0b_station.py +25 -34
- disdrodb/cli/disdrodb_run_l0c.py +130 -0
- disdrodb/cli/disdrodb_run_l0c_station.py +129 -0
- disdrodb/cli/disdrodb_run_l1.py +122 -0
- disdrodb/cli/disdrodb_run_l1_station.py +121 -0
- disdrodb/cli/disdrodb_run_l2e.py +122 -0
- disdrodb/cli/disdrodb_run_l2e_station.py +122 -0
- disdrodb/cli/disdrodb_run_l2m.py +122 -0
- disdrodb/cli/disdrodb_run_l2m_station.py +122 -0
- disdrodb/cli/disdrodb_upload_archive.py +105 -0
- disdrodb/cli/disdrodb_upload_station.py +98 -0
- disdrodb/configs.py +90 -25
- disdrodb/data_transfer/__init__.py +22 -0
- disdrodb/data_transfer/download_data.py +87 -90
- disdrodb/data_transfer/upload_data.py +64 -37
- disdrodb/data_transfer/zenodo.py +15 -18
- disdrodb/docs.py +1 -1
- disdrodb/issue/__init__.py +17 -4
- disdrodb/issue/checks.py +10 -23
- disdrodb/issue/reader.py +9 -12
- disdrodb/issue/writer.py +14 -17
- disdrodb/l0/__init__.py +17 -26
- disdrodb/l0/check_configs.py +35 -23
- disdrodb/l0/check_standards.py +32 -42
- disdrodb/l0/configs/{Thies_LPM → LPM}/bins_diameter.yml +44 -44
- disdrodb/l0/configs/{Thies_LPM → LPM}/bins_velocity.yml +40 -40
- disdrodb/l0/configs/LPM/l0a_encodings.yml +80 -0
- disdrodb/l0/configs/{Thies_LPM → LPM}/l0b_cf_attrs.yml +62 -59
- disdrodb/l0/configs/{Thies_LPM → LPM}/l0b_encodings.yml +9 -9
- disdrodb/l0/configs/{Thies_LPM → LPM}/raw_data_format.yml +245 -245
- disdrodb/l0/configs/{OTT_Parsivel → PARSIVEL}/bins_diameter.yml +66 -66
- disdrodb/l0/configs/{OTT_Parsivel → PARSIVEL}/bins_velocity.yml +64 -64
- disdrodb/l0/configs/PARSIVEL/l0a_encodings.yml +32 -0
- disdrodb/l0/configs/{OTT_Parsivel → PARSIVEL}/l0b_cf_attrs.yml +22 -20
- disdrodb/l0/configs/{OTT_Parsivel → PARSIVEL}/l0b_encodings.yml +17 -17
- disdrodb/l0/configs/{OTT_Parsivel → PARSIVEL}/raw_data_format.yml +77 -77
- disdrodb/l0/configs/{OTT_Parsivel2 → PARSIVEL2}/bins_diameter.yml +64 -64
- disdrodb/l0/configs/{OTT_Parsivel2 → PARSIVEL2}/bins_velocity.yml +64 -64
- disdrodb/l0/configs/PARSIVEL2/l0a_encodings.yml +39 -0
- disdrodb/l0/configs/{OTT_Parsivel2 → PARSIVEL2}/l0b_cf_attrs.yml +24 -22
- disdrodb/l0/configs/{OTT_Parsivel2 → PARSIVEL2}/l0b_encodings.yml +20 -20
- disdrodb/l0/configs/{OTT_Parsivel2 → PARSIVEL2}/raw_data_format.yml +98 -98
- disdrodb/l0/configs/{RD_80 → RD80}/bins_diameter.yml +40 -40
- disdrodb/l0/configs/RD80/l0a_encodings.yml +16 -0
- disdrodb/l0/configs/{RD_80 → RD80}/l0b_cf_attrs.yml +3 -3
- disdrodb/l0/configs/RD80/l0b_encodings.yml +135 -0
- disdrodb/l0/configs/{RD_80 → RD80}/raw_data_format.yml +48 -48
- disdrodb/l0/l0_reader.py +216 -340
- disdrodb/l0/l0a_processing.py +237 -208
- disdrodb/l0/l0b_nc_processing.py +227 -80
- disdrodb/l0/l0b_processing.py +93 -173
- disdrodb/l0/l0c_processing.py +627 -0
- disdrodb/l0/readers/{ARM → LPM/ARM}/ARM_LPM.py +36 -58
- disdrodb/l0/readers/LPM/AUSTRALIA/MELBOURNE_2007_LPM.py +226 -0
- disdrodb/l0/readers/LPM/BRAZIL/CHUVA_LPM.py +185 -0
- disdrodb/l0/readers/LPM/BRAZIL/GOAMAZON_LPM.py +183 -0
- disdrodb/l0/readers/LPM/ITALY/GID_LPM.py +179 -0
- disdrodb/l0/readers/{UK → LPM/UK}/DIVEN.py +14 -35
- disdrodb/l0/readers/PARSIVEL/AUSTRALIA/MELBOURNE_2007_PARSIVEL.py +157 -0
- disdrodb/l0/readers/PARSIVEL/CHINA/CHONGQING.py +113 -0
- disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/ARCTIC_2021.py +40 -57
- disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/COMMON_2011.py +37 -54
- disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/DAVOS_2009_2011.py +34 -51
- disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/EPFL_2009.py +34 -51
- disdrodb/l0/readers/{EPFL/PARADISO_2014.py → PARSIVEL/EPFL/EPFL_ROOF_2008.py} +38 -50
- disdrodb/l0/readers/PARSIVEL/EPFL/EPFL_ROOF_2010.py +105 -0
- disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/EPFL_ROOF_2011.py +34 -51
- disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/EPFL_ROOF_2012.py +33 -51
- disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/GENEPI_2007.py +25 -44
- disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/GRAND_ST_BERNARD_2007.py +25 -44
- disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/GRAND_ST_BERNARD_2007_2.py +25 -44
- disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/HPICONET_2010.py +34 -51
- disdrodb/l0/readers/{EPFL/EPFL_ROOF_2010.py → PARSIVEL/EPFL/HYMEX_LTE_SOP2.py} +37 -50
- disdrodb/l0/readers/PARSIVEL/EPFL/HYMEX_LTE_SOP3.py +111 -0
- disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/HYMEX_LTE_SOP4.py +36 -54
- disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/LOCARNO_2018.py +34 -52
- disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/LOCARNO_2019.py +38 -56
- disdrodb/l0/readers/PARSIVEL/EPFL/PARADISO_2014.py +105 -0
- disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/PARSIVEL_2007.py +27 -45
- disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/PLATO_2019.py +24 -44
- disdrodb/l0/readers/PARSIVEL/EPFL/RACLETS_2019.py +140 -0
- disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/RACLETS_2019_WJF.py +41 -59
- disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/RIETHOLZBACH_2011.py +34 -51
- disdrodb/l0/readers/PARSIVEL/EPFL/SAMOYLOV_2017.py +117 -0
- disdrodb/l0/readers/PARSIVEL/EPFL/SAMOYLOV_2019.py +137 -0
- disdrodb/l0/readers/{EPFL → PARSIVEL/EPFL}/UNIL_2022.py +42 -55
- disdrodb/l0/readers/PARSIVEL/GPM/IFLOODS.py +104 -0
- disdrodb/l0/readers/{GPM → PARSIVEL/GPM}/LPVEX.py +29 -48
- disdrodb/l0/readers/PARSIVEL/GPM/MC3E.py +184 -0
- disdrodb/l0/readers/PARSIVEL/NCAR/CCOPE_2015.py +113 -0
- disdrodb/l0/readers/{NCAR/VORTEX_SE_2016_P1.py → PARSIVEL/NCAR/OWLES_MIPS.py} +46 -72
- disdrodb/l0/readers/PARSIVEL/NCAR/PECAN_MOBILE.py +125 -0
- disdrodb/l0/readers/{NCAR/OWLES_MIPS.py → PARSIVEL/NCAR/PLOWS_MIPS.py} +45 -64
- disdrodb/l0/readers/PARSIVEL/NCAR/VORTEX2_2009.py +114 -0
- disdrodb/l0/readers/PARSIVEL/NCAR/VORTEX2_2010.py +176 -0
- disdrodb/l0/readers/PARSIVEL/NCAR/VORTEX2_2010_UF.py +183 -0
- disdrodb/l0/readers/{ARM/ARM_LD.py → PARSIVEL2/ARM/ARM_PARSIVEL2.py} +27 -50
- disdrodb/l0/readers/PARSIVEL2/BRAZIL/CHUVA_PARSIVEL2.py +163 -0
- disdrodb/l0/readers/PARSIVEL2/BRAZIL/GOAMAZON_PARSIVEL2.py +163 -0
- disdrodb/l0/readers/{DENMARK → PARSIVEL2/DENMARK}/EROSION_nc.py +14 -35
- disdrodb/l0/readers/PARSIVEL2/FRANCE/SIRTA_PARSIVEL2.py +119 -0
- disdrodb/l0/readers/PARSIVEL2/GPM/GCPEX.py +104 -0
- disdrodb/l0/readers/PARSIVEL2/GPM/NSSTC.py +176 -0
- disdrodb/l0/readers/PARSIVEL2/ITALY/GID_PARSIVEL2.py +32 -0
- disdrodb/l0/readers/PARSIVEL2/MEXICO/OH_IIUNAM_nc.py +56 -0
- disdrodb/l0/readers/PARSIVEL2/NCAR/PECAN_FP3.py +120 -0
- disdrodb/l0/readers/{NCAR → PARSIVEL2/NCAR}/PECAN_MIPS.py +45 -64
- disdrodb/l0/readers/PARSIVEL2/NCAR/RELAMPAGO_PARSIVEL2.py +181 -0
- disdrodb/l0/readers/PARSIVEL2/NCAR/SNOWIE_PJ.py +160 -0
- disdrodb/l0/readers/PARSIVEL2/NCAR/SNOWIE_SB.py +160 -0
- disdrodb/l0/readers/{NCAR/PLOWS_MIPS.py → PARSIVEL2/NCAR/VORTEX_SE_2016_P1.py} +49 -66
- disdrodb/l0/readers/PARSIVEL2/NCAR/VORTEX_SE_2016_P2.py +118 -0
- disdrodb/l0/readers/PARSIVEL2/NCAR/VORTEX_SE_2016_PIPS.py +152 -0
- disdrodb/l0/readers/PARSIVEL2/NETHERLANDS/DELFT.py +166 -0
- disdrodb/l0/readers/{NCAR/RELAMPAGO_RD80.py → RD80/BRAZIL/CHUVA_RD80.py} +36 -60
- disdrodb/l0/readers/{BRAZIL → RD80/BRAZIL}/GOAMAZON_RD80.py +36 -55
- disdrodb/l0/readers/{NCAR → RD80/NCAR}/CINDY_2011_RD80.py +35 -54
- disdrodb/l0/readers/{BRAZIL/CHUVA_RD80.py → RD80/NCAR/RELAMPAGO_RD80.py} +40 -54
- disdrodb/l0/readers/template_reader_raw_netcdf_data.py +62 -0
- disdrodb/l0/readers/{reader_template.py → template_reader_raw_text_data.py} +20 -44
- disdrodb/l0/routines.py +885 -581
- disdrodb/l0/standards.py +72 -236
- disdrodb/l0/template_tools.py +104 -109
- disdrodb/l1/__init__.py +17 -0
- disdrodb/l1/beard_model.py +716 -0
- disdrodb/l1/encoding_attrs.py +620 -0
- disdrodb/l1/fall_velocity.py +260 -0
- disdrodb/l1/filters.py +192 -0
- disdrodb/l1/processing.py +200 -0
- disdrodb/l1/resampling.py +236 -0
- disdrodb/l1/routines.py +357 -0
- disdrodb/l1_env/__init__.py +17 -0
- disdrodb/l1_env/routines.py +38 -0
- disdrodb/l2/__init__.py +17 -0
- disdrodb/l2/empirical_dsd.py +1735 -0
- disdrodb/l2/event.py +388 -0
- disdrodb/l2/processing.py +519 -0
- disdrodb/l2/processing_options.py +213 -0
- disdrodb/l2/routines.py +868 -0
- disdrodb/metadata/__init__.py +9 -2
- disdrodb/metadata/checks.py +165 -118
- disdrodb/metadata/download.py +81 -0
- disdrodb/metadata/geolocation.py +146 -0
- disdrodb/metadata/info.py +20 -13
- disdrodb/metadata/manipulation.py +1 -1
- disdrodb/metadata/reader.py +59 -8
- disdrodb/metadata/search.py +77 -144
- disdrodb/metadata/standards.py +7 -8
- disdrodb/metadata/writer.py +8 -14
- disdrodb/psd/__init__.py +38 -0
- disdrodb/psd/fitting.py +2146 -0
- disdrodb/psd/models.py +774 -0
- disdrodb/routines.py +1176 -0
- disdrodb/scattering/__init__.py +28 -0
- disdrodb/scattering/axis_ratio.py +344 -0
- disdrodb/scattering/routines.py +456 -0
- disdrodb/utils/__init__.py +17 -0
- disdrodb/utils/attrs.py +208 -0
- disdrodb/utils/cli.py +269 -0
- disdrodb/utils/compression.py +60 -42
- disdrodb/utils/dask.py +62 -0
- disdrodb/utils/decorators.py +110 -0
- disdrodb/utils/directories.py +107 -46
- disdrodb/utils/encoding.py +127 -0
- disdrodb/utils/list.py +29 -0
- disdrodb/utils/logger.py +168 -46
- disdrodb/utils/time.py +657 -0
- disdrodb/utils/warnings.py +30 -0
- disdrodb/utils/writer.py +57 -0
- disdrodb/utils/xarray.py +138 -47
- disdrodb/utils/yaml.py +0 -1
- disdrodb/viz/__init__.py +17 -0
- disdrodb/viz/plots.py +17 -0
- disdrodb-0.1.0.dist-info/METADATA +321 -0
- disdrodb-0.1.0.dist-info/RECORD +216 -0
- {disdrodb-0.0.21.dist-info → disdrodb-0.1.0.dist-info}/WHEEL +1 -1
- disdrodb-0.1.0.dist-info/entry_points.txt +30 -0
- disdrodb/data_transfer/scripts/disdrodb_download_archive.py +0 -53
- disdrodb/data_transfer/scripts/disdrodb_upload_archive.py +0 -57
- disdrodb/l0/configs/OTT_Parsivel/l0a_encodings.yml +0 -32
- disdrodb/l0/configs/OTT_Parsivel2/l0a_encodings.yml +0 -39
- disdrodb/l0/configs/RD_80/l0a_encodings.yml +0 -16
- disdrodb/l0/configs/RD_80/l0b_encodings.yml +0 -135
- disdrodb/l0/configs/Thies_LPM/l0a_encodings.yml +0 -80
- disdrodb/l0/io.py +0 -257
- disdrodb/l0/l0_processing.py +0 -1091
- disdrodb/l0/readers/AUSTRALIA/MELBOURNE_2007_OTT.py +0 -178
- disdrodb/l0/readers/AUSTRALIA/MELBOURNE_2007_THIES.py +0 -247
- disdrodb/l0/readers/BRAZIL/CHUVA_LPM.py +0 -204
- disdrodb/l0/readers/BRAZIL/CHUVA_OTT.py +0 -183
- disdrodb/l0/readers/BRAZIL/GOAMAZON_LPM.py +0 -204
- disdrodb/l0/readers/BRAZIL/GOAMAZON_OTT.py +0 -183
- disdrodb/l0/readers/CHINA/CHONGQING.py +0 -131
- disdrodb/l0/readers/EPFL/EPFL_ROOF_2008.py +0 -128
- disdrodb/l0/readers/EPFL/HYMEX_LTE_SOP2.py +0 -127
- disdrodb/l0/readers/EPFL/HYMEX_LTE_SOP3.py +0 -129
- disdrodb/l0/readers/EPFL/RACLETS_2019.py +0 -158
- disdrodb/l0/readers/EPFL/SAMOYLOV_2017.py +0 -136
- disdrodb/l0/readers/EPFL/SAMOYLOV_2019.py +0 -158
- disdrodb/l0/readers/FRANCE/SIRTA_OTT2.py +0 -138
- disdrodb/l0/readers/GPM/GCPEX.py +0 -123
- disdrodb/l0/readers/GPM/IFLOODS.py +0 -123
- disdrodb/l0/readers/GPM/MC3E.py +0 -123
- disdrodb/l0/readers/GPM/NSSTC.py +0 -164
- disdrodb/l0/readers/ITALY/GID.py +0 -199
- disdrodb/l0/readers/MEXICO/OH_IIUNAM_nc.py +0 -92
- disdrodb/l0/readers/NCAR/CCOPE_2015.py +0 -133
- disdrodb/l0/readers/NCAR/PECAN_FP3.py +0 -137
- disdrodb/l0/readers/NCAR/PECAN_MOBILE.py +0 -144
- disdrodb/l0/readers/NCAR/RELAMPAGO_OTT.py +0 -195
- disdrodb/l0/readers/NCAR/SNOWIE_PJ.py +0 -172
- disdrodb/l0/readers/NCAR/SNOWIE_SB.py +0 -179
- disdrodb/l0/readers/NCAR/VORTEX2_2009.py +0 -133
- disdrodb/l0/readers/NCAR/VORTEX2_2010.py +0 -188
- disdrodb/l0/readers/NCAR/VORTEX2_2010_UF.py +0 -191
- disdrodb/l0/readers/NCAR/VORTEX_SE_2016_P2.py +0 -135
- disdrodb/l0/readers/NCAR/VORTEX_SE_2016_PIPS.py +0 -170
- disdrodb/l0/readers/NETHERLANDS/DELFT.py +0 -187
- disdrodb/l0/readers/SPAIN/SBEGUERIA.py +0 -179
- disdrodb/l0/scripts/disdrodb_run_l0b_concat.py +0 -93
- disdrodb/l0/scripts/disdrodb_run_l0b_concat_station.py +0 -85
- disdrodb/utils/netcdf.py +0 -452
- disdrodb/utils/scripts.py +0 -102
- disdrodb-0.0.21.dist-info/AUTHORS.md +0 -18
- disdrodb-0.0.21.dist-info/METADATA +0 -186
- disdrodb-0.0.21.dist-info/RECORD +0 -168
- disdrodb-0.0.21.dist-info/entry_points.txt +0 -15
- /disdrodb/l0/configs/{RD_80 → RD80}/bins_velocity.yml +0 -0
- /disdrodb/l0/manuals/{Thies_LPM.pdf → LPM.pdf} +0 -0
- /disdrodb/l0/manuals/{ODM_470.pdf → ODM470.pdf} +0 -0
- /disdrodb/l0/manuals/{OTT_Parsivel.pdf → PARSIVEL.pdf} +0 -0
- /disdrodb/l0/manuals/{OTT_Parsivel2.pdf → PARSIVEL2.pdf} +0 -0
- /disdrodb/l0/manuals/{PWS_100.pdf → PWS100.pdf} +0 -0
- /disdrodb/l0/manuals/{RD_80.pdf → RD80.pdf} +0 -0
- {disdrodb-0.0.21.dist-info → disdrodb-0.1.0.dist-info/licenses}/LICENSE +0 -0
- {disdrodb-0.0.21.dist-info → disdrodb-0.1.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -----------------------------------------------------------------------------.
|
|
3
|
+
# Copyright (c) 2021-2023 DISDRODB developers
|
|
4
|
+
#
|
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
#
|
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
# -----------------------------------------------------------------------------.
|
|
18
|
+
import numpy as np
|
|
19
|
+
import pandas as pd
|
|
20
|
+
|
|
21
|
+
from disdrodb.l0.l0_reader import is_documented_by, reader_generic_docstring
|
|
22
|
+
from disdrodb.l0.l0a_processing import read_raw_text_file
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@is_documented_by(reader_generic_docstring)
|
|
26
|
+
def reader(
|
|
27
|
+
filepath,
|
|
28
|
+
logger=None,
|
|
29
|
+
):
|
|
30
|
+
"""Reader."""
|
|
31
|
+
##------------------------------------------------------------------------.
|
|
32
|
+
#### Define column names
|
|
33
|
+
column_names = ["TO_PARSE"]
|
|
34
|
+
|
|
35
|
+
##------------------------------------------------------------------------.
|
|
36
|
+
#### Define reader options
|
|
37
|
+
reader_kwargs = {}
|
|
38
|
+
# - Define delimiter
|
|
39
|
+
reader_kwargs["delimiter"] = "\\n"
|
|
40
|
+
# - Skip first row as columns names
|
|
41
|
+
# - Define encoding
|
|
42
|
+
reader_kwargs["encoding"] = "latin" # "ISO-8859-1"
|
|
43
|
+
# - Avoid first column to become df index !!!
|
|
44
|
+
reader_kwargs["index_col"] = False
|
|
45
|
+
# - Define behaviour when encountering bad lines
|
|
46
|
+
reader_kwargs["on_bad_lines"] = "skip"
|
|
47
|
+
# - Define reader engine
|
|
48
|
+
# - C engine is faster
|
|
49
|
+
# - Python engine is more feature-complete
|
|
50
|
+
reader_kwargs["engine"] = "python"
|
|
51
|
+
# - Define on-the-fly decompression of on-disk data
|
|
52
|
+
# - Available: gzip, bz2, zip
|
|
53
|
+
reader_kwargs["compression"] = "infer"
|
|
54
|
+
# - Strings to recognize as NA/NaN and replace with standard NA flags
|
|
55
|
+
# - Already included: '#N/A', '#N/A N/A', '#NA', '-1.#IND', '-1.#QNAN',
|
|
56
|
+
# '-NaN', '-nan', '1.#IND', '1.#QNAN', '<NA>', 'N/A',
|
|
57
|
+
# 'NA', 'NULL', 'NaN', 'n/a', 'nan', 'null'
|
|
58
|
+
reader_kwargs["na_values"] = ["na", "", "error"]
|
|
59
|
+
|
|
60
|
+
##------------------------------------------------------------------------.
|
|
61
|
+
#### Read the data
|
|
62
|
+
df = read_raw_text_file(
|
|
63
|
+
filepath=filepath,
|
|
64
|
+
column_names=column_names,
|
|
65
|
+
reader_kwargs=reader_kwargs,
|
|
66
|
+
logger=logger,
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
##------------------------------------------------------------------------.
|
|
70
|
+
#### Adapt the dataframe to adhere to DISDRODB L0 standards
|
|
71
|
+
# Create ID and Value columns
|
|
72
|
+
df = df["TO_PARSE"].str.split(":", expand=True, n=1)
|
|
73
|
+
df.columns = ["ID", "Value"]
|
|
74
|
+
|
|
75
|
+
# Select only rows with values
|
|
76
|
+
df = df[df["Value"].astype(bool)]
|
|
77
|
+
df = df[df["Value"].apply(lambda x: x is not None)]
|
|
78
|
+
|
|
79
|
+
# Drop rows with invalid IDs
|
|
80
|
+
# - Corrupted rows
|
|
81
|
+
valid_id_str = np.char.rjust(np.arange(0, 94).astype(str), width=2, fillchar="0")
|
|
82
|
+
df = df[df["ID"].astype(str).isin(valid_id_str)]
|
|
83
|
+
|
|
84
|
+
# Create the dataframe with each row corresponding to a timestep
|
|
85
|
+
# - Group rows based on when ID values restart
|
|
86
|
+
groups = df.groupby((df["ID"].astype(int).diff() <= 0).cumsum())
|
|
87
|
+
|
|
88
|
+
# Reshape the dataframe
|
|
89
|
+
group_dfs = []
|
|
90
|
+
for _, group in groups:
|
|
91
|
+
group_df = group.set_index("ID").T
|
|
92
|
+
group_dfs.append(group_df)
|
|
93
|
+
|
|
94
|
+
# Merge each timestep dataframe
|
|
95
|
+
# --> Missing columns are infilled by NaN
|
|
96
|
+
df = pd.concat(group_dfs, axis=0)
|
|
97
|
+
|
|
98
|
+
# Assign column names
|
|
99
|
+
column_dict = {
|
|
100
|
+
"01": "rainfall_rate_32bit",
|
|
101
|
+
"02": "rainfall_accumulated_32bit",
|
|
102
|
+
"03": "weather_code_synop_4680",
|
|
103
|
+
"04": "weather_code_synop_4677",
|
|
104
|
+
"05": "weather_code_metar_4678",
|
|
105
|
+
"06": "weather_code_nws",
|
|
106
|
+
"07": "reflectivity_32bit",
|
|
107
|
+
"08": "mor_visibility",
|
|
108
|
+
"09": "sample_interval",
|
|
109
|
+
"10": "laser_amplitude",
|
|
110
|
+
"11": "number_particles",
|
|
111
|
+
"12": "sensor_temperature",
|
|
112
|
+
# "13": "sensor_serial_number",
|
|
113
|
+
# "14": "firmware_iop",
|
|
114
|
+
# "15": "firmware_dsp",
|
|
115
|
+
"16": "sensor_heating_current",
|
|
116
|
+
"17": "sensor_battery_voltage",
|
|
117
|
+
"18": "sensor_status",
|
|
118
|
+
# "19": "start_time",
|
|
119
|
+
"20": "sensor_time",
|
|
120
|
+
"21": "sensor_date",
|
|
121
|
+
# "22": "station_name",
|
|
122
|
+
# "23": "station_number",
|
|
123
|
+
"24": "rainfall_amount_absolute_32bit",
|
|
124
|
+
"25": "error_code",
|
|
125
|
+
"30": "rainfall_rate_16_bit_30",
|
|
126
|
+
"31": "rainfall_rate_16_bit_1200",
|
|
127
|
+
"32": "rainfall_accumulated_16bit",
|
|
128
|
+
"90": "raw_drop_concentration",
|
|
129
|
+
"91": "raw_drop_average_velocity",
|
|
130
|
+
"93": "raw_drop_number",
|
|
131
|
+
}
|
|
132
|
+
df = df.rename(column_dict, axis=1)
|
|
133
|
+
|
|
134
|
+
# Keep only columns defined in the dictionary
|
|
135
|
+
df = df[list(column_dict.values())]
|
|
136
|
+
|
|
137
|
+
# Define datetime "time" column
|
|
138
|
+
df["time"] = df["sensor_date"] + "-" + df["sensor_time"]
|
|
139
|
+
df["time"] = pd.to_datetime(df["time"], format="%d.%m.%Y-%H:%M:%S", errors="coerce")
|
|
140
|
+
|
|
141
|
+
# Drop columns not agreeing with DISDRODB L0 standards
|
|
142
|
+
columns_to_drop = [
|
|
143
|
+
"sensor_date",
|
|
144
|
+
"sensor_time",
|
|
145
|
+
# "firmware_iop",
|
|
146
|
+
# "firmware_dsp",
|
|
147
|
+
# "sensor_serial_number",
|
|
148
|
+
# "station_name",
|
|
149
|
+
# "station_number",
|
|
150
|
+
]
|
|
151
|
+
df = df.drop(columns=columns_to_drop)
|
|
152
|
+
|
|
153
|
+
# Preprocess the raw spectrum and raw_drop_average_velocity
|
|
154
|
+
# - Add 0 before every ; if ; not preceded by a digit
|
|
155
|
+
# - Example: ';;1;;' --> '0;0;1;0;'
|
|
156
|
+
df["raw_drop_average_velocity"] = df["raw_drop_average_velocity"].str.replace(r"(?<!\d);", "0;", regex=True)
|
|
157
|
+
df["raw_drop_number"] = df["raw_drop_number"].str.replace(r"(?<!\d);", "0;", regex=True)
|
|
158
|
+
|
|
159
|
+
# Return the dataframe adhering to DISDRODB L0 standards
|
|
160
|
+
return df
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
+
|
|
2
3
|
# -----------------------------------------------------------------------------.
|
|
3
4
|
# Copyright (c) 2021-2023 DISDRODB developers
|
|
4
5
|
#
|
|
@@ -15,23 +16,21 @@
|
|
|
15
16
|
# You should have received a copy of the GNU General Public License
|
|
16
17
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
18
|
# -----------------------------------------------------------------------------.
|
|
18
|
-
|
|
19
|
+
"""Reader for the VORTEX SE 2016 PARSIVEL2 NCAR data."""
|
|
20
|
+
import pandas as pd
|
|
21
|
+
|
|
19
22
|
from disdrodb.l0.l0_reader import is_documented_by, reader_generic_docstring
|
|
23
|
+
from disdrodb.l0.l0a_processing import read_raw_text_file
|
|
20
24
|
|
|
21
25
|
|
|
22
26
|
@is_documented_by(reader_generic_docstring)
|
|
23
27
|
def reader(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
station_name,
|
|
27
|
-
# Processing options
|
|
28
|
-
force=False,
|
|
29
|
-
verbose=False,
|
|
30
|
-
parallel=False,
|
|
31
|
-
debugging_mode=False,
|
|
28
|
+
filepath,
|
|
29
|
+
logger=None,
|
|
32
30
|
):
|
|
31
|
+
"""Reader."""
|
|
33
32
|
##------------------------------------------------------------------------.
|
|
34
|
-
####
|
|
33
|
+
#### Define column names
|
|
35
34
|
column_names = [
|
|
36
35
|
"day",
|
|
37
36
|
"month",
|
|
@@ -50,7 +49,7 @@ def reader(
|
|
|
50
49
|
]
|
|
51
50
|
|
|
52
51
|
##------------------------------------------------------------------------.
|
|
53
|
-
####
|
|
52
|
+
#### Define reader options
|
|
54
53
|
reader_kwargs = {}
|
|
55
54
|
# - Define delimiter
|
|
56
55
|
reader_kwargs["delimiter"] = ","
|
|
@@ -61,6 +60,9 @@ def reader(
|
|
|
61
60
|
# - Define behaviour when encountering bad lines
|
|
62
61
|
reader_kwargs["on_bad_lines"] = "skip"
|
|
63
62
|
|
|
63
|
+
# - Define encoding
|
|
64
|
+
reader_kwargs["encoding"] = "ISO-8859-1"
|
|
65
|
+
|
|
64
66
|
# - Define reader engine
|
|
65
67
|
# - C engine is faster
|
|
66
68
|
# - Python engine is more feature-complete
|
|
@@ -71,67 +73,48 @@ def reader(
|
|
|
71
73
|
reader_kwargs["compression"] = "infer"
|
|
72
74
|
|
|
73
75
|
# - Strings to recognize as NA/NaN and replace with standard NA flags
|
|
74
|
-
# - Already included:
|
|
75
|
-
#
|
|
76
|
-
#
|
|
76
|
+
# - Already included: '#N/A', '#N/A N/A', '#NA', '-1.#IND', '-1.#QNAN',
|
|
77
|
+
# '-NaN', '-nan', '1.#IND', '1.#QNAN', '<NA>', 'N/A',
|
|
78
|
+
# 'NA', 'NULL', 'NaN', 'n/a', 'nan', 'null'
|
|
77
79
|
reader_kwargs["na_values"] = ["na", "", "error"]
|
|
78
80
|
|
|
79
81
|
# Skip first row as columns names
|
|
80
82
|
reader_kwargs["header"] = None
|
|
81
83
|
|
|
82
|
-
# - Define encoding
|
|
83
|
-
reader_kwargs["encoding"] = "ISO-8859-1"
|
|
84
|
-
|
|
85
84
|
##------------------------------------------------------------------------.
|
|
86
|
-
####
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
import pandas as pd
|
|
90
|
-
|
|
91
|
-
# - Define datetime 'time' column
|
|
92
|
-
df["time"] = (
|
|
93
|
-
df["day"].astype(str)
|
|
94
|
-
+ "-"
|
|
95
|
-
+ df["month"].astype(str)
|
|
96
|
-
+ "-"
|
|
97
|
-
+ df["year"].astype(str)
|
|
98
|
-
+ " "
|
|
99
|
-
+ df["hour_minute"].astype(str)
|
|
100
|
-
+ ":"
|
|
101
|
-
+ df["second"].astype(str)
|
|
102
|
-
)
|
|
103
|
-
df["time"] = pd.to_datetime(df["time"], format="%d-%m-%Y %H%M:%S", errors="coerce")
|
|
104
|
-
|
|
105
|
-
# - Drop columns not agreeing with DISDRODB L0 standards
|
|
106
|
-
columns_to_drop = [
|
|
107
|
-
"day",
|
|
108
|
-
"month",
|
|
109
|
-
"year",
|
|
110
|
-
"hour_minute",
|
|
111
|
-
"second",
|
|
112
|
-
]
|
|
113
|
-
df = df.drop(columns=columns_to_drop)
|
|
114
|
-
|
|
115
|
-
return df
|
|
116
|
-
|
|
117
|
-
##------------------------------------------------------------------------.
|
|
118
|
-
#### - Define glob pattern to search data files in <raw_dir>/data/<station_name>
|
|
119
|
-
glob_patterns = "*.dat"
|
|
120
|
-
|
|
121
|
-
####----------------------------------------------------------------------.
|
|
122
|
-
#### - Create L0A products
|
|
123
|
-
run_l0a(
|
|
124
|
-
raw_dir=raw_dir,
|
|
125
|
-
processed_dir=processed_dir,
|
|
126
|
-
station_name=station_name,
|
|
127
|
-
# Custom arguments of the reader for L0A processing
|
|
128
|
-
glob_patterns=glob_patterns,
|
|
85
|
+
#### Read the data
|
|
86
|
+
df = read_raw_text_file(
|
|
87
|
+
filepath=filepath,
|
|
129
88
|
column_names=column_names,
|
|
130
89
|
reader_kwargs=reader_kwargs,
|
|
131
|
-
|
|
132
|
-
# Processing options
|
|
133
|
-
force=force,
|
|
134
|
-
verbose=verbose,
|
|
135
|
-
parallel=parallel,
|
|
136
|
-
debugging_mode=debugging_mode,
|
|
90
|
+
logger=logger,
|
|
137
91
|
)
|
|
92
|
+
|
|
93
|
+
##------------------------------------------------------------------------.
|
|
94
|
+
#### Adapt the dataframe to adhere to DISDRODB L0 standards
|
|
95
|
+
# Define datetime 'time' column
|
|
96
|
+
df["time"] = (
|
|
97
|
+
df["day"].astype(str)
|
|
98
|
+
+ "-"
|
|
99
|
+
+ df["month"].astype(str)
|
|
100
|
+
+ "-"
|
|
101
|
+
+ df["year"].astype(str)
|
|
102
|
+
+ " "
|
|
103
|
+
+ df["hour_minute"].astype(str)
|
|
104
|
+
+ ":"
|
|
105
|
+
+ df["second"].astype(str)
|
|
106
|
+
)
|
|
107
|
+
df["time"] = pd.to_datetime(df["time"], format="%d-%m-%Y %H%M:%S")
|
|
108
|
+
|
|
109
|
+
# Drop columns not agreeing with DISDRODB L0 standards
|
|
110
|
+
columns_to_drop = [
|
|
111
|
+
"day",
|
|
112
|
+
"month",
|
|
113
|
+
"year",
|
|
114
|
+
"hour_minute",
|
|
115
|
+
"second",
|
|
116
|
+
]
|
|
117
|
+
df = df.drop(columns=columns_to_drop)
|
|
118
|
+
|
|
119
|
+
# Return the dataframe adhering to DISDRODB L0 standards
|
|
120
|
+
return df
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -----------------------------------------------------------------------------.
|
|
3
|
+
# Copyright (c) 2021-2023 DISDRODB developers
|
|
4
|
+
#
|
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
#
|
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
# -----------------------------------------------------------------------------.
|
|
18
|
+
import pandas as pd
|
|
19
|
+
|
|
20
|
+
from disdrodb.l0.l0_reader import is_documented_by, reader_generic_docstring
|
|
21
|
+
from disdrodb.l0.l0a_processing import read_raw_text_file
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@is_documented_by(reader_generic_docstring)
|
|
25
|
+
def reader(
|
|
26
|
+
filepath,
|
|
27
|
+
logger=None,
|
|
28
|
+
):
|
|
29
|
+
"""Reader."""
|
|
30
|
+
##------------------------------------------------------------------------.
|
|
31
|
+
#### Define column names
|
|
32
|
+
column_names = [
|
|
33
|
+
"date",
|
|
34
|
+
"time",
|
|
35
|
+
"sensor_battery_voltage",
|
|
36
|
+
"laser_amplitude",
|
|
37
|
+
"sensor_heating_current",
|
|
38
|
+
"sensor_temperature",
|
|
39
|
+
"number_particles",
|
|
40
|
+
"mor_visibility",
|
|
41
|
+
"rainfall_rate_32bit",
|
|
42
|
+
"rainfall_accumulated_32bit",
|
|
43
|
+
"weather_code_synop_4680",
|
|
44
|
+
"reflectivity_32bit",
|
|
45
|
+
"weather_code_nws",
|
|
46
|
+
"weather_code_metar_4678",
|
|
47
|
+
"raw_drop_number",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
##------------------------------------------------------------------------.
|
|
51
|
+
#### Define reader options
|
|
52
|
+
reader_kwargs = {}
|
|
53
|
+
# - Define delimiter
|
|
54
|
+
reader_kwargs["delimiter"] = ","
|
|
55
|
+
|
|
56
|
+
# - Avoid first column to become df index !!!
|
|
57
|
+
reader_kwargs["index_col"] = False
|
|
58
|
+
|
|
59
|
+
# - Define behaviour when encountering bad lines
|
|
60
|
+
reader_kwargs["on_bad_lines"] = "skip"
|
|
61
|
+
|
|
62
|
+
# - Define encoding
|
|
63
|
+
reader_kwargs["encoding"] = "ISO-8859-1"
|
|
64
|
+
|
|
65
|
+
# - Define reader engine
|
|
66
|
+
# - C engine is faster
|
|
67
|
+
# - Python engine is more feature-complete
|
|
68
|
+
reader_kwargs["engine"] = "python"
|
|
69
|
+
|
|
70
|
+
# - Define on-the-fly decompression of on-disk data
|
|
71
|
+
# - Available: gzip, bz2, zip
|
|
72
|
+
reader_kwargs["compression"] = "infer"
|
|
73
|
+
|
|
74
|
+
# - Strings to recognize as NA/NaN and replace with standard NA flags
|
|
75
|
+
# - Already included: '#N/A', '#N/A N/A', '#NA', '-1.#IND', '-1.#QNAN',
|
|
76
|
+
# '-NaN', '-nan', '1.#IND', '1.#QNAN', '<NA>', 'N/A',
|
|
77
|
+
# 'NA', 'NULL', 'NaN', 'n/a', 'nan', 'null'
|
|
78
|
+
reader_kwargs["na_values"] = ["na", "", "error"]
|
|
79
|
+
|
|
80
|
+
# Skip first row as columns names
|
|
81
|
+
reader_kwargs["header"] = None
|
|
82
|
+
|
|
83
|
+
##------------------------------------------------------------------------.
|
|
84
|
+
#### Read the data
|
|
85
|
+
df = read_raw_text_file(
|
|
86
|
+
filepath=filepath,
|
|
87
|
+
column_names=column_names,
|
|
88
|
+
reader_kwargs=reader_kwargs,
|
|
89
|
+
logger=logger,
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
##------------------------------------------------------------------------.
|
|
93
|
+
#### Adapt the dataframe to adhere to DISDRODB L0 standards
|
|
94
|
+
# Define datetime 'time' column
|
|
95
|
+
df["time"] = df["date"] + "-" + df["time"]
|
|
96
|
+
df["time"] = pd.to_datetime(df["time"], format="%Y%m%d-%H:%M:%S", errors="coerce")
|
|
97
|
+
|
|
98
|
+
# Preprocess the raw spectrum
|
|
99
|
+
# - The '<SPECTRUM>ZERO</SPECTRUM>' indicates no drops detected
|
|
100
|
+
# --> "" generates an array of zeros in L0B processing
|
|
101
|
+
df["raw_drop_number"] = df["raw_drop_number"].astype("string")
|
|
102
|
+
df["raw_drop_number"] = df["raw_drop_number"].str.strip()
|
|
103
|
+
df["raw_drop_number"] = df["raw_drop_number"].replace("<SPECTRUM>ZERO</SPECTRUM>", "")
|
|
104
|
+
|
|
105
|
+
# Remove <SPECTRUM> and </SPECTRUM>" acronyms from the raw_drop_number field
|
|
106
|
+
df["raw_drop_number"] = df["raw_drop_number"].str.replace("<SPECTRUM>", "")
|
|
107
|
+
df["raw_drop_number"] = df["raw_drop_number"].str.replace("</SPECTRUM>", "")
|
|
108
|
+
|
|
109
|
+
# Preprocess the raw spectrum and raw_drop_average_velocity
|
|
110
|
+
# - Add 0 before every ; if ; not preceded by a digit
|
|
111
|
+
# - Example: ';;1;;' --> '0;0;1;0;'
|
|
112
|
+
df["raw_drop_number"] = df["raw_drop_number"].str.replace(r"(?<!\d);", "0;", regex=True)
|
|
113
|
+
|
|
114
|
+
# Drop columns not agreeing with DISDRODB L0 standards
|
|
115
|
+
df = df.drop(columns=["date"])
|
|
116
|
+
|
|
117
|
+
# Return the dataframe adhering to DISDRODB L0 standards
|
|
118
|
+
return df
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -----------------------------------------------------------------------------.
|
|
3
|
+
# Copyright (c) 2021-2023 DISDRODB developers
|
|
4
|
+
#
|
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
#
|
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
# -----------------------------------------------------------------------------.
|
|
18
|
+
import pandas as pd
|
|
19
|
+
|
|
20
|
+
from disdrodb.l0.l0_reader import is_documented_by, reader_generic_docstring
|
|
21
|
+
from disdrodb.l0.l0a_processing import read_raw_text_file
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@is_documented_by(reader_generic_docstring)
|
|
25
|
+
def reader(
|
|
26
|
+
filepath,
|
|
27
|
+
logger=None,
|
|
28
|
+
):
|
|
29
|
+
"""Reader."""
|
|
30
|
+
##------------------------------------------------------------------------.
|
|
31
|
+
#### Define column names
|
|
32
|
+
column_names = [
|
|
33
|
+
"logger_time",
|
|
34
|
+
"record_number",
|
|
35
|
+
"battery_voltage",
|
|
36
|
+
"logger_temperature",
|
|
37
|
+
"wind_direction",
|
|
38
|
+
"wind_speed",
|
|
39
|
+
"wind_flag",
|
|
40
|
+
"fast_temperature",
|
|
41
|
+
"slow_temperature",
|
|
42
|
+
"relative_humidity",
|
|
43
|
+
"pressure",
|
|
44
|
+
"compass_direction",
|
|
45
|
+
"gps_time",
|
|
46
|
+
"gps_status",
|
|
47
|
+
"gps_latitude", # DD.DM, DM = decimal minutes/100, DD = degrees
|
|
48
|
+
"gps_latitude_hemisphere", # N/S
|
|
49
|
+
"gps_longitude",
|
|
50
|
+
"gps_longitude_hemisphere", # W/E
|
|
51
|
+
"gps_speed",
|
|
52
|
+
"gps_direction",
|
|
53
|
+
"gps_date",
|
|
54
|
+
"gps_magnetic_version",
|
|
55
|
+
"gps_altitude",
|
|
56
|
+
"relative_wind_direction",
|
|
57
|
+
"dew_point_temperature",
|
|
58
|
+
"rh",
|
|
59
|
+
"disdrometer_data",
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
##------------------------------------------------------------------------.
|
|
63
|
+
#### Define reader options
|
|
64
|
+
reader_kwargs = {}
|
|
65
|
+
# - Define delimiter
|
|
66
|
+
reader_kwargs["delimiter"] = ","
|
|
67
|
+
|
|
68
|
+
# - Avoid first column to become df index !!!
|
|
69
|
+
reader_kwargs["index_col"] = False
|
|
70
|
+
|
|
71
|
+
# - Define behaviour when encountering bad lines
|
|
72
|
+
reader_kwargs["on_bad_lines"] = "skip"
|
|
73
|
+
|
|
74
|
+
# - Define encoding
|
|
75
|
+
reader_kwargs["encoding"] = "ISO-8859-1"
|
|
76
|
+
|
|
77
|
+
# - Define reader engine
|
|
78
|
+
# - C engine is faster
|
|
79
|
+
# - Python engine is more feature-complete
|
|
80
|
+
reader_kwargs["engine"] = "python"
|
|
81
|
+
|
|
82
|
+
# - Define on-the-fly decompression of on-disk data
|
|
83
|
+
# - Available: gzip, bz2, zip
|
|
84
|
+
reader_kwargs["compression"] = "infer"
|
|
85
|
+
|
|
86
|
+
# - Strings to recognize as NA/NaN and replace with standard NA flags
|
|
87
|
+
# - Already included: '#N/A', '#N/A N/A', '#NA', '-1.#IND', '-1.#QNAN',
|
|
88
|
+
# '-NaN', '-nan', '1.#IND', '1.#QNAN', '<NA>', 'N/A',
|
|
89
|
+
# 'NA', 'NULL', 'NaN', 'n/a', 'nan', 'null'
|
|
90
|
+
reader_kwargs["na_values"] = ["na", "", "error"]
|
|
91
|
+
|
|
92
|
+
# Skip first row as columns names
|
|
93
|
+
reader_kwargs["header"] = None
|
|
94
|
+
|
|
95
|
+
##------------------------------------------------------------------------.
|
|
96
|
+
#### Read the data
|
|
97
|
+
df = read_raw_text_file(
|
|
98
|
+
filepath=filepath,
|
|
99
|
+
column_names=column_names,
|
|
100
|
+
reader_kwargs=reader_kwargs,
|
|
101
|
+
logger=logger,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
##------------------------------------------------------------------------.
|
|
105
|
+
#### Adapt the dataframe to adhere to DISDRODB L0 standards
|
|
106
|
+
# Drop timesteps without disdrometer data
|
|
107
|
+
df = df[~df["disdrometer_data"].isna()]
|
|
108
|
+
|
|
109
|
+
# Retrieve disdrometer data
|
|
110
|
+
df_data = df["disdrometer_data"].str.split(";", expand=True, n=11)
|
|
111
|
+
|
|
112
|
+
# Assign column names
|
|
113
|
+
column_names = [
|
|
114
|
+
"serial_number",
|
|
115
|
+
"rainfall_rate_32bit",
|
|
116
|
+
"rainfall_accumulated_32bit",
|
|
117
|
+
"reflectivity_32bit",
|
|
118
|
+
"sample_interval",
|
|
119
|
+
"laser_amplitude",
|
|
120
|
+
"number_particles",
|
|
121
|
+
"sensor_temperature",
|
|
122
|
+
"sensor_battery_voltage",
|
|
123
|
+
"sensor_time", # Note: logger_time is currently used !
|
|
124
|
+
"sensor_date",
|
|
125
|
+
"raw_drop_number",
|
|
126
|
+
]
|
|
127
|
+
df_data.columns = column_names
|
|
128
|
+
|
|
129
|
+
# Retrieve time and coordinates information
|
|
130
|
+
# --> Latitude in degrees_north
|
|
131
|
+
# --> Longitude in degrees_east
|
|
132
|
+
df_time = pd.to_datetime(df["logger_time"], errors="coerce")
|
|
133
|
+
df_lat_sign = df["gps_latitude_hemisphere"].str.replace("N", "1").str.replace("S", "-1")
|
|
134
|
+
df_lon_sign = df["gps_longitude_hemisphere"].str.replace("E", "1").str.replace("W", "-1")
|
|
135
|
+
df_lat_sign = df_lat_sign.astype(float)
|
|
136
|
+
df_lon_sign = df_lon_sign.astype(float)
|
|
137
|
+
df_lon = df["gps_longitude"].astype(float)
|
|
138
|
+
df_lat = df["gps_latitude"].astype(float)
|
|
139
|
+
df_lon = df_lon * df_lon_sign
|
|
140
|
+
df_lat = df_lat * df_lat_sign
|
|
141
|
+
|
|
142
|
+
# Create dataframe
|
|
143
|
+
df = df_data
|
|
144
|
+
df["time"] = df_time
|
|
145
|
+
df["latitude"] = df_lat
|
|
146
|
+
df["longitude"] = df_lon
|
|
147
|
+
|
|
148
|
+
# Drop columns not agreeing with DISDRODB L0 standards
|
|
149
|
+
df = df.drop(columns=["serial_number", "sensor_time", "sensor_date", "serial_number"])
|
|
150
|
+
|
|
151
|
+
# Return the dataframe adhering to DISDRODB L0 standards
|
|
152
|
+
return df
|