disdrodb 0.3.0__py3-none-any.whl → 0.4.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 (198) hide show
  1. disdrodb/__init__.py +2 -0
  2. disdrodb/_config.py +1 -0
  3. disdrodb/_version.py +2 -2
  4. disdrodb/accessor/__init__.py +1 -0
  5. disdrodb/accessor/methods.py +1 -0
  6. disdrodb/api/checks.py +2 -4
  7. disdrodb/api/io.py +224 -24
  8. disdrodb/api/path.py +2 -4
  9. disdrodb/cli/disdrodb_check_metadata_archive.py +1 -0
  10. disdrodb/cli/disdrodb_check_products_options.py +1 -0
  11. disdrodb/cli/disdrodb_create_summary.py +6 -6
  12. disdrodb/cli/disdrodb_create_summary_station.py +2 -2
  13. disdrodb/cli/disdrodb_data_archive_directory.py +1 -0
  14. disdrodb/cli/disdrodb_download_archive.py +5 -6
  15. disdrodb/cli/disdrodb_download_metadata_archive.py +1 -0
  16. disdrodb/cli/disdrodb_download_station.py +2 -3
  17. disdrodb/cli/disdrodb_initialize_station.py +3 -3
  18. disdrodb/cli/disdrodb_metadata_archive_directory.py +1 -0
  19. disdrodb/cli/disdrodb_open_data_archive.py +1 -2
  20. disdrodb/cli/disdrodb_open_logs_directory.py +2 -3
  21. disdrodb/cli/disdrodb_open_metadata_archive.py +1 -2
  22. disdrodb/cli/disdrodb_open_metadata_directory.py +2 -3
  23. disdrodb/cli/disdrodb_open_product_directory.py +1 -2
  24. disdrodb/cli/disdrodb_open_readers_directory.py +1 -0
  25. disdrodb/cli/disdrodb_run.py +6 -6
  26. disdrodb/cli/disdrodb_run_l0.py +6 -6
  27. disdrodb/cli/disdrodb_run_l0_station.py +3 -3
  28. disdrodb/cli/disdrodb_run_l0a.py +6 -6
  29. disdrodb/cli/disdrodb_run_l0a_station.py +3 -3
  30. disdrodb/cli/disdrodb_run_l0b.py +6 -6
  31. disdrodb/cli/disdrodb_run_l0b_station.py +3 -3
  32. disdrodb/cli/disdrodb_run_l0c.py +6 -6
  33. disdrodb/cli/disdrodb_run_l0c_station.py +3 -3
  34. disdrodb/cli/disdrodb_run_l1.py +6 -6
  35. disdrodb/cli/disdrodb_run_l1_station.py +3 -3
  36. disdrodb/cli/disdrodb_run_l2e.py +6 -6
  37. disdrodb/cli/disdrodb_run_l2e_station.py +3 -3
  38. disdrodb/cli/disdrodb_run_l2m.py +6 -6
  39. disdrodb/cli/disdrodb_run_l2m_station.py +3 -3
  40. disdrodb/cli/disdrodb_run_station.py +3 -3
  41. disdrodb/cli/disdrodb_upload_archive.py +6 -7
  42. disdrodb/cli/disdrodb_upload_station.py +3 -4
  43. disdrodb/configs.py +7 -8
  44. disdrodb/constants.py +1 -0
  45. disdrodb/data_transfer/download_data.py +8 -8
  46. disdrodb/data_transfer/upload_data.py +6 -8
  47. disdrodb/data_transfer/zenodo.py +1 -1
  48. disdrodb/fall_velocity/__init__.py +1 -0
  49. disdrodb/fall_velocity/graupel.py +1 -0
  50. disdrodb/fall_velocity/hail.py +1 -0
  51. disdrodb/fall_velocity/rain.py +1 -0
  52. disdrodb/issue/checks.py +1 -0
  53. disdrodb/issue/reader.py +1 -0
  54. disdrodb/issue/writer.py +1 -2
  55. disdrodb/l0/__init__.py +1 -0
  56. disdrodb/l0/check_configs.py +21 -23
  57. disdrodb/l0/check_standards.py +0 -1
  58. disdrodb/l0/configs/LPM/l0a_encodings.yml +17 -17
  59. disdrodb/l0/configs/LPM/l0b_cf_attrs.yml +55 -55
  60. disdrodb/l0/configs/LPM/l0b_encodings.yml +17 -17
  61. disdrodb/l0/configs/LPM/raw_data_format.yml +17 -17
  62. disdrodb/l0/configs/LPM_V0/l0a_encodings.yml +2 -2
  63. disdrodb/l0/configs/LPM_V0/l0b_cf_attrs.yml +2 -2
  64. disdrodb/l0/configs/LPM_V0/l0b_encodings.yml +2 -2
  65. disdrodb/l0/configs/LPM_V0/raw_data_format.yml +2 -2
  66. disdrodb/l0/l0_reader.py +1 -0
  67. disdrodb/l0/l0a_processing.py +5 -5
  68. disdrodb/l0/l0b_nc_processing.py +1 -2
  69. disdrodb/l0/l0b_processing.py +1 -13
  70. disdrodb/l0/l0c_processing.py +2 -1
  71. disdrodb/l0/readers/LPM/ARM/ARM_LPM.py +1 -0
  72. disdrodb/l0/readers/LPM/AUSTRALIA/MELBOURNE_2007_LPM.py +17 -17
  73. disdrodb/l0/readers/LPM/BRAZIL/CHUVA_LPM.py +17 -17
  74. disdrodb/l0/readers/LPM/BRAZIL/GOAMAZON_LPM.py +17 -17
  75. disdrodb/l0/readers/LPM/GERMANY/DWD.py +55 -52
  76. disdrodb/l0/readers/LPM/ITALY/GID_LPM.py +18 -17
  77. disdrodb/l0/readers/LPM/ITALY/GID_LPM_AQ.py +277 -0
  78. disdrodb/l0/readers/LPM/ITALY/GID_LPM_PI.py +18 -17
  79. disdrodb/l0/readers/LPM/ITALY/GID_LPM_T.py +18 -17
  80. disdrodb/l0/readers/LPM/ITALY/GID_LPM_W.py +18 -18
  81. disdrodb/l0/readers/LPM/KIT/CHWALA.py +18 -17
  82. disdrodb/l0/readers/LPM/NETHERLANDS/DELFT_RWANDA_LPM_NC.py +17 -17
  83. disdrodb/l0/readers/LPM/NORWAY/HAUKELISETER_LPM.py +18 -17
  84. disdrodb/l0/readers/LPM/NORWAY/NMBU_LPM.py +18 -17
  85. disdrodb/l0/readers/LPM/SLOVENIA/ARSO.py +18 -17
  86. disdrodb/l0/readers/LPM/SLOVENIA/UL.py +18 -17
  87. disdrodb/l0/readers/LPM/SWITZERLAND/INNERERIZ_LPM.py +18 -17
  88. disdrodb/l0/readers/LPM/UK/WITHWORTH_LPM.py +18 -17
  89. disdrodb/l0/readers/LPM/USA/CHARLESTON.py +18 -17
  90. disdrodb/l0/readers/LPM/USA/DEVEX.py +255 -0
  91. disdrodb/l0/readers/LPM_V0/BELGIUM/ULIEGE.py +2 -2
  92. disdrodb/l0/readers/LPM_V0/ITALY/GID_LPM_V0.py +3 -2
  93. disdrodb/l0/readers/ODM470/OCEAN/OCEANRAIN.py +1 -0
  94. disdrodb/l0/readers/PARSIVEL/BASQUECOUNTRY/EUSKALMET_OTT.py +1 -0
  95. disdrodb/l0/readers/PARSIVEL/CHINA/CHONGQING.py +1 -0
  96. disdrodb/l0/readers/PARSIVEL/EPFL/ARCTIC_2021.py +1 -0
  97. disdrodb/l0/readers/PARSIVEL/EPFL/COMMON_2011.py +1 -0
  98. disdrodb/l0/readers/PARSIVEL/EPFL/DAVOS_2009_2011.py +1 -0
  99. disdrodb/l0/readers/PARSIVEL/EPFL/EPFL_2009.py +1 -0
  100. disdrodb/l0/readers/PARSIVEL/EPFL/EPFL_ROOF_2008.py +1 -0
  101. disdrodb/l0/readers/PARSIVEL/EPFL/EPFL_ROOF_2010.py +1 -0
  102. disdrodb/l0/readers/PARSIVEL/EPFL/EPFL_ROOF_2011.py +1 -0
  103. disdrodb/l0/readers/PARSIVEL/EPFL/EPFL_ROOF_2012.py +1 -0
  104. disdrodb/l0/readers/PARSIVEL/EPFL/GENEPI_2007.py +1 -0
  105. disdrodb/l0/readers/PARSIVEL/EPFL/GRAND_ST_BERNARD_2007.py +1 -0
  106. disdrodb/l0/readers/PARSIVEL/EPFL/GRAND_ST_BERNARD_2007_2.py +1 -0
  107. disdrodb/l0/readers/PARSIVEL/EPFL/HPICONET_2010.py +1 -0
  108. disdrodb/l0/readers/PARSIVEL/EPFL/HYMEX_LTE_SOP2.py +1 -0
  109. disdrodb/l0/readers/PARSIVEL/EPFL/HYMEX_LTE_SOP3.py +1 -0
  110. disdrodb/l0/readers/PARSIVEL/EPFL/HYMEX_LTE_SOP4.py +1 -0
  111. disdrodb/l0/readers/PARSIVEL/EPFL/PARADISO_2014.py +1 -0
  112. disdrodb/l0/readers/PARSIVEL/EPFL/PARSIVEL_2007.py +1 -0
  113. disdrodb/l0/readers/PARSIVEL/EPFL/RACLETS_2019.py +1 -0
  114. disdrodb/l0/readers/PARSIVEL/EPFL/RACLETS_2019_WJF.py +1 -0
  115. disdrodb/l0/readers/PARSIVEL/EPFL/RIETHOLZBACH_2011.py +1 -0
  116. disdrodb/l0/readers/PARSIVEL/EPFL/SAMOYLOV_2017.py +1 -0
  117. disdrodb/l0/readers/PARSIVEL/EPFL/SAMOYLOV_2019.py +1 -0
  118. disdrodb/l0/readers/PARSIVEL/EPFL/UNIL_2022.py +1 -0
  119. disdrodb/l0/readers/PARSIVEL/SLOVENIA/UL.py +1 -0
  120. disdrodb/l0/readers/PARSIVEL2/ARM/ARM_PARSIVEL2.py +1 -0
  121. disdrodb/l0/readers/PARSIVEL2/BASQUECOUNTRY/EUSKALMET_OTT2.py +1 -0
  122. disdrodb/l0/readers/PARSIVEL2/BELGIUM/ILVO.py +1 -0
  123. disdrodb/l0/readers/PARSIVEL2/DENMARK/EROSION_nc.py +1 -0
  124. disdrodb/l0/readers/PARSIVEL2/DENMARK/EROSION_raw.py +1 -0
  125. disdrodb/l0/readers/PARSIVEL2/FRANCE/ENPC_PARSIVEL2.py +1 -0
  126. disdrodb/l0/readers/PARSIVEL2/FRANCE/OSUG.py +1 -1
  127. disdrodb/l0/readers/PARSIVEL2/ITALY/HYDROX.py +1 -0
  128. disdrodb/l0/readers/PARSIVEL2/MEXICO/OH_IIUNAM_nc.py +1 -0
  129. disdrodb/l0/readers/PARSIVEL2/NCAR/FARM_PARSIVEL2.py +1 -0
  130. disdrodb/l0/readers/PARSIVEL2/NCAR/PERILS_MIPS.py +1 -0
  131. disdrodb/l0/readers/PARSIVEL2/NCAR/PERILS_PIPS.py +1 -0
  132. disdrodb/l0/readers/PARSIVEL2/NCAR/VORTEX_SE_2016_P1.py +1 -0
  133. disdrodb/l0/readers/PARSIVEL2/NCAR/VORTEX_SE_2016_PIPS.py +1 -0
  134. disdrodb/l0/readers/PARSIVEL2/PHILIPPINES/PAGASA.py +1 -0
  135. disdrodb/l0/readers/PARSIVEL2/SPAIN/GRANADA.py +1 -0
  136. disdrodb/l0/readers/PARSIVEL2/SWEDEN/SMHI.py +1 -0
  137. disdrodb/l0/readers/PARSIVEL2/USA/CW3E.py +1 -0
  138. disdrodb/l0/readers/PWS100/AUSTRIA/HOAL.py +1 -0
  139. disdrodb/l0/readers/PWS100/FRANCE/ENPC_PWS100.py +1 -0
  140. disdrodb/l0/readers/PWS100/FRANCE/ENPC_PWS100_SIRTA.py +1 -0
  141. disdrodb/l0/readers/RD80/NOAA/PSL_RD80.py +1 -0
  142. disdrodb/l0/readers/SWS250/BELGIUM/KMI.py +1 -0
  143. disdrodb/l0/readers/template_reader_raw_netcdf_data.py +1 -0
  144. disdrodb/l0/readers/template_reader_raw_text_data.py +1 -0
  145. disdrodb/l0/template_tools.py +6 -8
  146. disdrodb/l1/__init__.py +1 -0
  147. disdrodb/l1/classification.py +1 -0
  148. disdrodb/l1/resampling.py +5 -0
  149. disdrodb/l1_env/routines.py +1 -0
  150. disdrodb/l2/__init__.py +1 -0
  151. disdrodb/l2/empirical_dsd.py +1 -0
  152. disdrodb/l2/processing.py +1 -0
  153. disdrodb/metadata/checks.py +9 -10
  154. disdrodb/metadata/download.py +1 -0
  155. disdrodb/metadata/geolocation.py +2 -1
  156. disdrodb/metadata/info.py +2 -2
  157. disdrodb/metadata/search.py +0 -1
  158. disdrodb/physics/atmosphere.py +1 -0
  159. disdrodb/physics/water.py +1 -0
  160. disdrodb/physics/wrappers.py +1 -0
  161. disdrodb/psd/__init__.py +0 -1
  162. disdrodb/psd/fitting.py +1 -0
  163. disdrodb/psd/models.py +1 -0
  164. disdrodb/routines/__init__.py +1 -0
  165. disdrodb/routines/l0.py +13 -9
  166. disdrodb/routines/l1.py +17 -12
  167. disdrodb/routines/l2.py +4 -5
  168. disdrodb/routines/options.py +1 -0
  169. disdrodb/routines/options_validation.py +12 -12
  170. disdrodb/routines/wrappers.py +33 -33
  171. disdrodb/scattering/__init__.py +0 -1
  172. disdrodb/scattering/permittivity.py +1 -0
  173. disdrodb/scattering/routines.py +3 -3
  174. disdrodb/summary/routines.py +12 -5
  175. disdrodb/utils/archiving.py +2 -1
  176. disdrodb/utils/attrs.py +3 -2
  177. disdrodb/utils/compression.py +1 -2
  178. disdrodb/utils/coords.py +45 -0
  179. disdrodb/utils/dask.py +5 -2
  180. disdrodb/utils/dataframe.py +4 -3
  181. disdrodb/utils/decorators.py +2 -1
  182. disdrodb/utils/directories.py +2 -2
  183. disdrodb/utils/encoding.py +2 -1
  184. disdrodb/utils/manipulations.py +1 -0
  185. disdrodb/utils/pydantic.py +1 -0
  186. disdrodb/utils/routines.py +1 -0
  187. disdrodb/utils/time.py +3 -2
  188. disdrodb/utils/warnings.py +1 -0
  189. disdrodb/utils/writer.py +4 -0
  190. disdrodb/utils/xarray.py +1 -0
  191. disdrodb/viz/plots.py +1 -0
  192. {disdrodb-0.3.0.dist-info → disdrodb-0.4.0.dist-info}/METADATA +4 -3
  193. disdrodb-0.4.0.dist-info/RECORD +361 -0
  194. disdrodb-0.3.0.dist-info/RECORD +0 -358
  195. {disdrodb-0.3.0.dist-info → disdrodb-0.4.0.dist-info}/WHEEL +0 -0
  196. {disdrodb-0.3.0.dist-info → disdrodb-0.4.0.dist-info}/entry_points.txt +0 -0
  197. {disdrodb-0.3.0.dist-info → disdrodb-0.4.0.dist-info}/licenses/LICENSE +0 -0
  198. {disdrodb-0.3.0.dist-info → disdrodb-0.4.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,277 @@
1
+ # -----------------------------------------------------------------------------.
2
+ # Copyright (c) 2021-2026 DISDRODB developers
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ # -----------------------------------------------------------------------------.
17
+ """DISDRODB reader for GID LPM sensors not measuring wind."""
18
+
19
+ import os
20
+
21
+ import numpy as np
22
+ import pandas as pd
23
+
24
+ from disdrodb.l0.l0_reader import is_documented_by, reader_generic_docstring
25
+ from disdrodb.l0.l0a_processing import read_raw_text_file
26
+ from disdrodb.utils.logger import log_warning
27
+
28
+
29
+ @is_documented_by(reader_generic_docstring)
30
+ def reader(
31
+ filepath,
32
+ logger=None,
33
+ ):
34
+ """Reader."""
35
+ ##------------------------------------------------------------------------.
36
+ #### - Define raw data headers
37
+ column_names = ["TO_PARSE"]
38
+
39
+ ##------------------------------------------------------------------------.
40
+ #### Define reader options
41
+ # - For more info: https://pandas.pydata.org/docs/reference/api/pandas.read_csv.html
42
+ reader_kwargs = {}
43
+
44
+ # - Define delimiter
45
+ reader_kwargs["delimiter"] = "\\n"
46
+
47
+ # - Avoid first column to become df index !!!
48
+ reader_kwargs["index_col"] = False
49
+
50
+ # Since column names are expected to be passed explicitly, header is set to None
51
+ reader_kwargs["header"] = None
52
+
53
+ # - Number of rows to be skipped at the beginning of the file
54
+ reader_kwargs["skiprows"] = None
55
+
56
+ # - Define encoding
57
+ reader_kwargs["encoding"] = "latin"
58
+
59
+ # - Define behaviour when encountering bad lines
60
+ reader_kwargs["on_bad_lines"] = "skip"
61
+
62
+ # - Define reader engine
63
+ # - C engine is faster
64
+ # - Python engine is more feature-complete
65
+ reader_kwargs["engine"] = "python"
66
+
67
+ # - Define on-the-fly decompression of on-disk data
68
+ # - Available: gzip, bz2, zip
69
+ reader_kwargs["compression"] = "infer"
70
+
71
+ # - Strings to recognize as NA/NaN and replace with standard NA flags
72
+ # - Already included: '#N/A', '#N/A N/A', '#NA', '-1.#IND', '-1.#QNAN',
73
+ # '-NaN', '-nan', '1.#IND', '1.#QNAN', '<NA>', 'N/A',
74
+ # 'NA', 'NULL', 'NaN', 'n/a', 'nan', 'null'
75
+ reader_kwargs["na_values"] = ["na", "", "error"]
76
+
77
+ ##------------------------------------------------------------------------.
78
+ #### Read the data
79
+ df = read_raw_text_file(
80
+ filepath=filepath,
81
+ column_names=column_names,
82
+ reader_kwargs=reader_kwargs,
83
+ logger=logger,
84
+ )
85
+
86
+ ##------------------------------------------------------------------------.
87
+ #### Adapt the dataframe to adhere to DISDRODB L0 standards
88
+ # Raise error if empty file
89
+ if len(df) == 0:
90
+ raise ValueError(f"{filepath} is empty.")
91
+
92
+ # Select only rows with expected number of delimiters
93
+ df = df[df["TO_PARSE"].str.count(";").isin([519, 520, 523])]
94
+
95
+ # Check there are still valid rows
96
+ if len(df) == 0:
97
+ raise ValueError(f"No valid rows in {filepath}.")
98
+
99
+ # Split by ; delimiter (before raw drop number)
100
+ df = df["TO_PARSE"].str.split(";", expand=True, n=79)
101
+
102
+ # Assign column names
103
+ names = [
104
+ "start_identifier",
105
+ "device_address",
106
+ "sensor_serial_number",
107
+ "sensor_date",
108
+ "sensor_time",
109
+ "weather_code_synop_4677_5min",
110
+ "weather_code_synop_4680_5min",
111
+ "weather_code_metar_4678_5min",
112
+ "precipitation_rate_5min",
113
+ "weather_code_synop_4677",
114
+ "weather_code_synop_4680",
115
+ "weather_code_metar_4678",
116
+ "precipitation_rate",
117
+ "rainfall_rate",
118
+ "snowfall_rate",
119
+ "precipitation_accumulated",
120
+ "mor_visibility",
121
+ "reflectivity",
122
+ "quality_index",
123
+ "max_hail_diameter",
124
+ "laser_status",
125
+ "static_signal_status",
126
+ "laser_temperature_analog_status",
127
+ "laser_temperature_digital_status",
128
+ "laser_current_analog_status",
129
+ "laser_current_digital_status",
130
+ "sensor_voltage_supply_status",
131
+ "current_heating_pane_transmitter_head_status",
132
+ "current_heating_pane_receiver_head_status",
133
+ "temperature_sensor_status",
134
+ "current_heating_voltage_supply_status",
135
+ "current_heating_house_status",
136
+ "current_heating_heads_status",
137
+ "current_heating_carriers_status",
138
+ "control_output_laser_power_status",
139
+ "reserved_status",
140
+ "temperature_interior",
141
+ "laser_temperature",
142
+ "laser_current_average",
143
+ "control_voltage",
144
+ "optical_control_voltage_output",
145
+ "sensor_voltage_supply",
146
+ "current_heating_pane_transmitter_head",
147
+ "current_heating_pane_receiver_head",
148
+ "temperature_ambient",
149
+ "current_heating_voltage_supply",
150
+ "current_heating_house",
151
+ "current_heating_heads",
152
+ "current_heating_carriers",
153
+ "number_particles",
154
+ "number_particles_internal_data",
155
+ "number_particles_min_speed",
156
+ "number_particles_min_speed_internal_data",
157
+ "number_particles_max_speed",
158
+ "number_particles_max_speed_internal_data",
159
+ "number_particles_min_diameter",
160
+ "number_particles_min_diameter_internal_data",
161
+ "number_particles_no_hydrometeor",
162
+ "number_particles_no_hydrometeor_internal_data",
163
+ "number_particles_unknown_classification",
164
+ "total_gross_volume_unknown_classification",
165
+ "number_particles_hail",
166
+ "total_gross_volume_hail",
167
+ "number_particles_solid_precipitation",
168
+ "total_gross_volume_solid_precipitation",
169
+ "number_particles_large_pellet",
170
+ "total_gross_volume_large_pellet",
171
+ "number_particles_small_pellet",
172
+ "total_gross_volume_small_pellet",
173
+ "number_particles_snowgrain",
174
+ "total_gross_volume_snowgrain",
175
+ "number_particles_rain",
176
+ "total_gross_volume_rain",
177
+ "number_particles_small_rain",
178
+ "total_gross_volume_small_rain",
179
+ "number_particles_drizzle",
180
+ "total_gross_volume_drizzle",
181
+ "number_particles_class_9",
182
+ "number_particles_class_9_internal_data",
183
+ "TO_BE_FURTHER_PROCESSED",
184
+ ]
185
+ df.columns = names
186
+
187
+ # Extract the last variables remained in raw_drop_number
188
+ if df["TO_BE_FURTHER_PROCESSED"].iloc[0].count(";") == 444:
189
+ df_parsed = df["TO_BE_FURTHER_PROCESSED"].str.rsplit(";", n=5, expand=True)
190
+ df_parsed.columns = [
191
+ "raw_drop_number",
192
+ "air_temperature", # only values between 0 and 2
193
+ "relative_humidity", # 999
194
+ "wind_speed",
195
+ "wind_direction",
196
+ "checksum",
197
+ ]
198
+
199
+ else: # 440
200
+ df_parsed = df["TO_BE_FURTHER_PROCESSED"].str.rsplit(";", n=1, expand=True)
201
+ df_parsed.columns = [
202
+ "raw_drop_number",
203
+ "checksum",
204
+ ]
205
+ # Add missing met variables columns
206
+ met_vars = [
207
+ "air_temperature",
208
+ "relative_humidity",
209
+ "wind_speed",
210
+ "wind_direction",
211
+ ]
212
+ for var in met_vars:
213
+ df_parsed[var] = "NaN"
214
+
215
+ # Assign columns to the original dataframe
216
+ df[df_parsed.columns] = df_parsed
217
+
218
+ # Identify rows with bad sensor date (compared to file name)
219
+ filename = os.path.basename(filepath)
220
+ file_date_str = filename[0:8]
221
+ idx_bad_date = df["sensor_date"] != pd.to_datetime(file_date_str, format="%Y%m%d").strftime("%d.%m.%y")
222
+
223
+ # If all rows have bad sensor_date, use the one of the file name
224
+ if idx_bad_date.all():
225
+ # - Infer and define "time" column
226
+ start_time_str = filename[0:10]
227
+ start_time = pd.to_datetime(start_time_str, format="%Y%m%d%H")
228
+
229
+ # - Define timedelta based on sensor_time
230
+ # --> Add +24h to subsequent times when time resets
231
+ dt = pd.to_timedelta(df["sensor_time"]).to_numpy().astype("m8[s]")
232
+ rollover_indices = np.where(np.diff(dt) < np.timedelta64(0, "s"))[0]
233
+ if rollover_indices.size > 0:
234
+ for idx in rollover_indices:
235
+ dt[idx + 1 :] += np.timedelta64(24, "h")
236
+ dt = dt - dt[0]
237
+
238
+ # - Define approximate time
239
+ df["time"] = start_time + dt
240
+
241
+ # - Keep rows where time increment is between 00 and 59 minutes
242
+ valid_rows = dt <= np.timedelta64(3540, "s")
243
+ df = df[valid_rows]
244
+
245
+ # If only some rows have bad sensor date, just drop such bad rows
246
+ else:
247
+ if idx_bad_date.any():
248
+ # Remove rows with bad dates
249
+ bad_dates = df[idx_bad_date]["sensor_date"].unique().tolist()
250
+ df = df[~idx_bad_date]
251
+ msg = f"{filepath} contain rows with the following unexpected sensor_date values {bad_dates}"
252
+ log_warning(msg=msg, logger=logger)
253
+
254
+ # Define datetime "time" column
255
+ df["time"] = df["sensor_date"] + "-" + df["sensor_time"]
256
+ df["time"] = pd.to_datetime(df["time"], format="%d.%m.%y-%H:%M:%S", errors="coerce")
257
+
258
+ # Drop row if start_identifier different than 00
259
+ df = df[df["start_identifier"].astype(str) == "00"]
260
+
261
+ # Drop rows with invalid raw_drop_number
262
+ df = df[df["raw_drop_number"].astype(str).str.len() == 1759]
263
+
264
+ # Drop columns not agreeing with DISDRODB L0 standards
265
+ columns_to_drop = [
266
+ "start_identifier",
267
+ "device_address",
268
+ "sensor_serial_number",
269
+ "sensor_date",
270
+ "sensor_time",
271
+ "air_temperature",
272
+ "relative_humidity",
273
+ "TO_BE_FURTHER_PROCESSED",
274
+ "checksum",
275
+ ]
276
+ df = df.drop(columns=columns_to_drop)
277
+ return df
@@ -15,6 +15,7 @@
15
15
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  # -----------------------------------------------------------------------------.
17
17
  """DISDRODB reader for GID LPM sensor TC-PI with incorrect reported time."""
18
+
18
19
  import pandas as pd
19
20
 
20
21
  from disdrodb.l0.l0_reader import is_documented_by, reader_generic_docstring
@@ -152,23 +153,23 @@ def read_txt_file(file, filename, logger):
152
153
  "number_particles_no_hydrometeor",
153
154
  "number_particles_no_hydrometeor_internal_data",
154
155
  "number_particles_unknown_classification",
155
- "number_particles_unknown_classification_internal_data",
156
- "number_particles_class_1",
157
- "number_particles_class_1_internal_data",
158
- "number_particles_class_2",
159
- "number_particles_class_2_internal_data",
160
- "number_particles_class_3",
161
- "number_particles_class_3_internal_data",
162
- "number_particles_class_4",
163
- "number_particles_class_4_internal_data",
164
- "number_particles_class_5",
165
- "number_particles_class_5_internal_data",
166
- "number_particles_class_6",
167
- "number_particles_class_6_internal_data",
168
- "number_particles_class_7",
169
- "number_particles_class_7_internal_data",
170
- "number_particles_class_8",
171
- "number_particles_class_8_internal_data",
156
+ "total_gross_volume_unknown_classification",
157
+ "number_particles_hail",
158
+ "total_gross_volume_hail",
159
+ "number_particles_solid_precipitation",
160
+ "total_gross_volume_solid_precipitation",
161
+ "number_particles_large_pellet",
162
+ "total_gross_volume_large_pellet",
163
+ "number_particles_small_pellet",
164
+ "total_gross_volume_small_pellet",
165
+ "number_particles_snowgrain",
166
+ "total_gross_volume_snowgrain",
167
+ "number_particles_rain",
168
+ "total_gross_volume_rain",
169
+ "number_particles_small_rain",
170
+ "total_gross_volume_small_rain",
171
+ "number_particles_drizzle",
172
+ "total_gross_volume_drizzle",
172
173
  "number_particles_class_9",
173
174
  "number_particles_class_9_internal_data",
174
175
  "TO_BE_FURTHER_PROCESSED",
@@ -15,6 +15,7 @@
15
15
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  # -----------------------------------------------------------------------------.
17
17
  """DISDRODB reader for GID LPM sensors not reporting time (TC-MI2, TC-MI3, TC-ER e TC-FI)."""
18
+
18
19
  import numpy as np
19
20
  import pandas as pd
20
21
 
@@ -146,23 +147,23 @@ def read_txt_file(file, filename, logger):
146
147
  "number_particles_no_hydrometeor",
147
148
  "number_particles_no_hydrometeor_internal_data",
148
149
  "number_particles_unknown_classification",
149
- "number_particles_unknown_classification_internal_data",
150
- "number_particles_class_1",
151
- "number_particles_class_1_internal_data",
152
- "number_particles_class_2",
153
- "number_particles_class_2_internal_data",
154
- "number_particles_class_3",
155
- "number_particles_class_3_internal_data",
156
- "number_particles_class_4",
157
- "number_particles_class_4_internal_data",
158
- "number_particles_class_5",
159
- "number_particles_class_5_internal_data",
160
- "number_particles_class_6",
161
- "number_particles_class_6_internal_data",
162
- "number_particles_class_7",
163
- "number_particles_class_7_internal_data",
164
- "number_particles_class_8",
165
- "number_particles_class_8_internal_data",
150
+ "total_gross_volume_unknown_classification",
151
+ "number_particles_hail",
152
+ "total_gross_volume_hail",
153
+ "number_particles_solid_precipitation",
154
+ "total_gross_volume_solid_precipitation",
155
+ "number_particles_large_pellet",
156
+ "total_gross_volume_large_pellet",
157
+ "number_particles_small_pellet",
158
+ "total_gross_volume_small_pellet",
159
+ "number_particles_snowgrain",
160
+ "total_gross_volume_snowgrain",
161
+ "number_particles_rain",
162
+ "total_gross_volume_rain",
163
+ "number_particles_small_rain",
164
+ "total_gross_volume_small_rain",
165
+ "number_particles_drizzle",
166
+ "total_gross_volume_drizzle",
166
167
  "number_particles_class_9",
167
168
  "number_particles_class_9_internal_data",
168
169
  "raw_drop_number",
@@ -15,6 +15,7 @@
15
15
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  # -----------------------------------------------------------------------------.
17
17
  """DISDRODB reader for GID LPM sensors measuring also wind."""
18
+
18
19
  import pandas as pd
19
20
 
20
21
  from disdrodb.l0.l0_reader import is_documented_by, reader_generic_docstring
@@ -145,23 +146,23 @@ def reader(
145
146
  "number_particles_no_hydrometeor",
146
147
  "number_particles_no_hydrometeor_internal_data",
147
148
  "number_particles_unknown_classification",
148
- "number_particles_unknown_classification_internal_data",
149
- "number_particles_class_1",
150
- "number_particles_class_1_internal_data",
151
- "number_particles_class_2",
152
- "number_particles_class_2_internal_data",
153
- "number_particles_class_3",
154
- "number_particles_class_3_internal_data",
155
- "number_particles_class_4",
156
- "number_particles_class_4_internal_data",
157
- "number_particles_class_5",
158
- "number_particles_class_5_internal_data",
159
- "number_particles_class_6",
160
- "number_particles_class_6_internal_data",
161
- "number_particles_class_7",
162
- "number_particles_class_7_internal_data",
163
- "number_particles_class_8",
164
- "number_particles_class_8_internal_data",
149
+ "total_gross_volume_unknown_classification",
150
+ "number_particles_hail",
151
+ "total_gross_volume_hail",
152
+ "number_particles_solid_precipitation",
153
+ "total_gross_volume_solid_precipitation",
154
+ "number_particles_large_pellet",
155
+ "total_gross_volume_large_pellet",
156
+ "number_particles_small_pellet",
157
+ "total_gross_volume_small_pellet",
158
+ "number_particles_snowgrain",
159
+ "total_gross_volume_snowgrain",
160
+ "number_particles_rain",
161
+ "total_gross_volume_rain",
162
+ "number_particles_small_rain",
163
+ "total_gross_volume_small_rain",
164
+ "number_particles_drizzle",
165
+ "total_gross_volume_drizzle",
165
166
  "number_particles_class_9",
166
167
  "number_particles_class_9_internal_data",
167
168
  "TO_BE_FURTHER_PROCESSED",
@@ -204,5 +205,4 @@ def reader(
204
205
  "TO_BE_FURTHER_PROCESSED",
205
206
  ]
206
207
  df = df.drop(columns=columns_to_drop)
207
-
208
208
  return df
@@ -15,6 +15,7 @@
15
15
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  # -----------------------------------------------------------------------------.
17
17
  """DISDRODB reader for GID LPM sensors not measuring wind."""
18
+
18
19
  import os
19
20
 
20
21
  import pandas as pd
@@ -149,23 +150,23 @@ def reader(
149
150
  "number_particles_no_hydrometeor",
150
151
  "number_particles_no_hydrometeor_internal_data",
151
152
  "number_particles_unknown_classification",
152
- "number_particles_unknown_classification_internal_data",
153
- "number_particles_class_1",
154
- "number_particles_class_1_internal_data",
155
- "number_particles_class_2",
156
- "number_particles_class_2_internal_data",
157
- "number_particles_class_3",
158
- "number_particles_class_3_internal_data",
159
- "number_particles_class_4",
160
- "number_particles_class_4_internal_data",
161
- "number_particles_class_5",
162
- "number_particles_class_5_internal_data",
163
- "number_particles_class_6",
164
- "number_particles_class_6_internal_data",
165
- "number_particles_class_7",
166
- "number_particles_class_7_internal_data",
167
- "number_particles_class_8",
168
- "number_particles_class_8_internal_data",
153
+ "total_gross_volume_unknown_classification",
154
+ "number_particles_hail",
155
+ "total_gross_volume_hail",
156
+ "number_particles_solid_precipitation",
157
+ "total_gross_volume_solid_precipitation",
158
+ "number_particles_large_pellet",
159
+ "total_gross_volume_large_pellet",
160
+ "number_particles_small_pellet",
161
+ "total_gross_volume_small_pellet",
162
+ "number_particles_snowgrain",
163
+ "total_gross_volume_snowgrain",
164
+ "number_particles_rain",
165
+ "total_gross_volume_rain",
166
+ "number_particles_small_rain",
167
+ "total_gross_volume_small_rain",
168
+ "number_particles_drizzle",
169
+ "total_gross_volume_drizzle",
169
170
  "number_particles_class_9",
170
171
  "number_particles_class_9_internal_data",
171
172
  "raw_drop_number",
@@ -74,23 +74,23 @@ def reader(
74
74
  "number_of_particles_faster_than_20": "number_particles_max_speed",
75
75
  "number_of_particles_smaller_than_0.15": "number_particles_min_diameter",
76
76
  "number_of_particles_with_unknown_classification": "number_particles_unknown_classification",
77
- "total_volume_gross_particles_unknown_classification": "number_particles_unknown_classification_internal_data",
78
- "number_of_particles_class_1": "number_particles_class_1",
79
- "total_volume_gross_of_class_1": "number_particles_class_1_internal_data",
80
- "number_of_particles_class_2": "number_particles_class_2",
81
- "total_volume_gross_of_class_2": "number_particles_class_2_internal_data",
82
- "number_of_particles_class_3": "number_particles_class_3",
83
- "total_volume_gross_of_class_3": "number_particles_class_3_internal_data",
84
- "number_of_particles_class_4": "number_particles_class_4",
85
- "total_volume_gross_of_class_4": "number_particles_class_4_internal_data",
86
- "number_of_particles_class_5": "number_particles_class_5",
87
- "total_volume_gross_of_class_5": "number_particles_class_5_internal_data",
88
- "number_of_particles_class_6": "number_particles_class_6",
89
- "total_volume_gross_of_class_6": "number_particles_class_6_internal_data",
90
- "number_of_particles_class_7": "number_particles_class_7",
91
- "total_volume_gross_of_class_7": "number_particles_class_7_internal_data",
92
- "number_of_particles_class_8": "number_particles_class_8",
93
- "total_volume_gross_of_class_8": "number_particles_class_8_internal_data",
77
+ "total_volume_gross_particles_unknown_classification": "total_gross_volume_unknown_classification",
78
+ "number_of_particles_class_1": "number_particles_hail",
79
+ "total_volume_gross_of_class_1": "total_gross_volume_hail",
80
+ "number_of_particles_class_2": "number_particles_solid_precipitation",
81
+ "total_volume_gross_of_class_2": "total_gross_volume_solid_precipitation",
82
+ "number_of_particles_class_3": "number_particles_large_pellet",
83
+ "total_volume_gross_of_class_3": "total_gross_volume_large_pellet",
84
+ "number_of_particles_class_4": "number_particles_small_pellet",
85
+ "total_volume_gross_of_class_4": "total_gross_volume_small_pellet",
86
+ "number_of_particles_class_5": "number_particles_snowgrain",
87
+ "total_volume_gross_of_class_5": "total_gross_volume_snowgrain",
88
+ "number_of_particles_class_6": "number_particles_rain",
89
+ "total_volume_gross_of_class_6": "total_gross_volume_rain",
90
+ "number_of_particles_class_7": "number_particles_small_rain",
91
+ "total_volume_gross_of_class_7": "total_gross_volume_small_rain",
92
+ "number_of_particles_class_8": "number_particles_drizzle",
93
+ "total_volume_gross_of_class_8": "total_gross_volume_drizzle",
94
94
  "number_of_particles_class_9": "number_particles_class_9",
95
95
  "total_volume_gross_of_class_9": "number_particles_class_9_internal_data",
96
96
  "raw_data": "raw_drop_number",
@@ -15,6 +15,7 @@
15
15
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  # -----------------------------------------------------------------------------.
17
17
  """DISDRODB reader for Haukeliseter Test Site LPM sensors."""
18
+
18
19
  import numpy as np
19
20
  import pandas as pd
20
21
 
@@ -167,23 +168,23 @@ def reader(
167
168
  "number_particles_no_hydrometeor",
168
169
  "number_particles_no_hydrometeor_internal_data",
169
170
  "number_particles_unknown_classification",
170
- "number_particles_unknown_classification_internal_data",
171
- "number_particles_class_1",
172
- "number_particles_class_1_internal_data",
173
- "number_particles_class_2",
174
- "number_particles_class_2_internal_data",
175
- "number_particles_class_3",
176
- "number_particles_class_3_internal_data",
177
- "number_particles_class_4",
178
- "number_particles_class_4_internal_data",
179
- "number_particles_class_5",
180
- "number_particles_class_5_internal_data",
181
- "number_particles_class_6",
182
- "number_particles_class_6_internal_data",
183
- "number_particles_class_7",
184
- "number_particles_class_7_internal_data",
185
- "number_particles_class_8",
186
- "number_particles_class_8_internal_data",
171
+ "total_gross_volume_unknown_classification",
172
+ "number_particles_hail",
173
+ "total_gross_volume_hail",
174
+ "number_particles_solid_precipitation",
175
+ "total_gross_volume_solid_precipitation",
176
+ "number_particles_large_pellet",
177
+ "total_gross_volume_large_pellet",
178
+ "number_particles_small_pellet",
179
+ "total_gross_volume_small_pellet",
180
+ "number_particles_snowgrain",
181
+ "total_gross_volume_snowgrain",
182
+ "number_particles_rain",
183
+ "total_gross_volume_rain",
184
+ "number_particles_small_rain",
185
+ "total_gross_volume_small_rain",
186
+ "number_particles_drizzle",
187
+ "total_gross_volume_drizzle",
187
188
  "number_particles_class_9",
188
189
  "number_particles_class_9_internal_data",
189
190
  "raw_drop_number",
@@ -15,6 +15,7 @@
15
15
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  # -----------------------------------------------------------------------------.
17
17
  """DISDRODB reader for NMBU BIOKLIM LPM sensor."""
18
+
18
19
  import os
19
20
 
20
21
  import pandas as pd
@@ -156,23 +157,23 @@ def reader(
156
157
  "number_particles_no_hydrometeor",
157
158
  "number_particles_no_hydrometeor_internal_data",
158
159
  "number_particles_unknown_classification",
159
- "number_particles_unknown_classification_internal_data",
160
- "number_particles_class_1",
161
- "number_particles_class_1_internal_data",
162
- "number_particles_class_2",
163
- "number_particles_class_2_internal_data",
164
- "number_particles_class_3",
165
- "number_particles_class_3_internal_data",
166
- "number_particles_class_4",
167
- "number_particles_class_4_internal_data",
168
- "number_particles_class_5",
169
- "number_particles_class_5_internal_data",
170
- "number_particles_class_6",
171
- "number_particles_class_6_internal_data",
172
- "number_particles_class_7",
173
- "number_particles_class_7_internal_data",
174
- "number_particles_class_8",
175
- "number_particles_class_8_internal_data",
160
+ "total_gross_volume_unknown_classification",
161
+ "number_particles_hail",
162
+ "total_gross_volume_hail",
163
+ "number_particles_solid_precipitation",
164
+ "total_gross_volume_solid_precipitation",
165
+ "number_particles_large_pellet",
166
+ "total_gross_volume_large_pellet",
167
+ "number_particles_small_pellet",
168
+ "total_gross_volume_small_pellet",
169
+ "number_particles_snowgrain",
170
+ "total_gross_volume_snowgrain",
171
+ "number_particles_rain",
172
+ "total_gross_volume_rain",
173
+ "number_particles_small_rain",
174
+ "total_gross_volume_small_rain",
175
+ "number_particles_drizzle",
176
+ "total_gross_volume_drizzle",
176
177
  "number_particles_class_9",
177
178
  "number_particles_class_9_internal_data",
178
179
  "raw_drop_number",