pyadps 0.1.0__py3-none-any.whl → 0.1.0b0__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.
pyadps/utils/writenc.py CHANGED
@@ -17,6 +17,7 @@ from netCDF4 import date2num
17
17
  from pyadps.utils import readrdi as rd
18
18
 
19
19
 
20
+
20
21
  def pd2nctime(time, t0="hours since 2000-01-01"):
21
22
  """
22
23
  Function to convert pandas datetime format to netcdf datetime format.
@@ -67,16 +68,9 @@ def flead_ncatt(fl_obj, ncfile_id, ens=0):
67
68
  setattr(ncfile_id, format_key, format(value))
68
69
 
69
70
 
70
- def rawnc(
71
- infile,
72
- outfile,
73
- time,
74
- axis_option=None,
75
- attributes=None,
76
- t0="hours since 2000-01-01",
77
- ):
71
+ def main(infile, outfile, attributes=None):
78
72
  """
79
- rawnc is a function to create netcdf file. Stores 3-D data types like
73
+ Main function to create netcdf file. Stores 3-D data types like
80
74
  velocity, echo, correlation, and percent good.
81
75
 
82
76
  Args:
@@ -96,33 +90,14 @@ def rawnc(
96
90
  beam_list = flead.fleader["Beams"]
97
91
 
98
92
  # Dimensions
99
- # Define the primary axis based on axis_option
100
- if axis_option == "ensemble":
101
- outnc.createDimension("ensemble", None)
102
- primary_axis = "ensemble"
103
- ensemble = outnc.createVariable("ensemble", "i4", ("ensemble",))
104
- ensemble.axis = "T"
105
- elif axis_option == "time":
106
- tsize = len(time)
107
- outnc.createDimension("time", tsize)
108
- primary_axis = "time"
109
- time_var = outnc.createVariable("time", "i4", ("time",))
110
- time_var.axis = "T"
111
- time_var.units = t0
112
- time_var.long_name = "time"
113
-
114
- # Convert time_data to numerical format
115
- nctime = pd2nctime(time, t0)
116
- time_var[:] = nctime
117
-
118
- else:
119
- raise ValueError(f"Invalid axis_option: {axis_option}.")
120
-
93
+ outnc.createDimension("ensemble", None)
121
94
  outnc.createDimension("cell", max(cell_list))
122
95
  outnc.createDimension("beam", max(beam_list))
123
96
 
124
97
  # Variables
125
98
  # Dimension Variables
99
+ ensemble = outnc.createVariable("ensemble", "u4", ("ensemble",))
100
+ ensemble.axis = "T"
126
101
  cell = outnc.createVariable("cell", "i2", ("cell",))
127
102
  cell.axis = "Z"
128
103
  beam = outnc.createVariable("beam", "i2", ("beam",))
@@ -143,9 +118,9 @@ def rawnc(
143
118
  for i, item in enumerate(varlist):
144
119
  if item == "Velocity":
145
120
  varid[i] = outnc.createVariable(
146
- item, "i2", (primary_axis, "cell", "beam"), fill_value=-32768
121
+ item, "i2", ("ensemble", "cell", "beam"), fill_value=-32768
147
122
  )
148
- # varid[i].missing_value = -32768
123
+ varid[i].missing_value = -32768
149
124
  vel = getattr(rd, item)
150
125
  var = vel(infile).data
151
126
  # var = rd.variables(infile, item)
@@ -154,7 +129,7 @@ def rawnc(
154
129
  # Unsigned integers might be assigned for future netcdf versions
155
130
  format_item = item.replace(" ", "") # For percent good
156
131
  varid[i] = outnc.createVariable(
157
- format_item, "i2", (primary_axis, "cell", "beam")
132
+ format_item, "i2", ("ensemble", "cell", "beam")
158
133
  )
159
134
  datatype = getattr(rd, format_item)
160
135
  var = np.array(datatype(infile).data, dtype="int16")
@@ -162,32 +137,22 @@ def rawnc(
162
137
 
163
138
  vshape = var.T.shape
164
139
  if i == 0:
165
- if primary_axis == "ensemble":
166
- ensemble[:] = np.arange(1, vshape[0] + 1, 1)
167
-
140
+ ensemble[:] = np.arange(1, vshape[0] + 1, 1)
168
141
  varid[i][0 : vshape[0], 0 : vshape[1], 0 : vshape[2]] = var.T
169
-
142
+
170
143
  # Add global attributes if provided
171
144
  if attributes:
172
145
  for key, value in attributes.items():
173
- setattr(
174
- outnc, key, str(value)
175
- ) # Convert to string to store in NetCDF metadata
146
+ setattr(outnc, key, str(value)) # Convert to string to store in NetCDF metadata
176
147
 
177
148
  # outnc.history = "Created " + time.ctime(time.time())
178
149
  flead_ncatt(flead, outnc)
150
+
179
151
 
180
152
  outnc.close()
181
153
 
182
154
 
183
- def vlead_nc(
184
- infile,
185
- outfile,
186
- time,
187
- axis_option=None,
188
- attributes=None,
189
- t0="hours since 2000-01-01",
190
- ):
155
+ def vlead_nc(infile, outfile, attributes=None):
191
156
  """
192
157
  Function to create ncfile containing Variable Leader.
193
158
 
@@ -198,29 +163,12 @@ def vlead_nc(
198
163
  outnc = nc4.Dataset(outfile, "w", format="NETCDF4")
199
164
 
200
165
  # Dimensions
201
- # Define the primary axis based on axis_option
202
- if axis_option == "ensemble":
203
- outnc.createDimension("ensemble", None)
204
- primary_axis = "ensemble"
205
- ensemble = outnc.createVariable("ensemble", "i4", ("ensemble",))
206
- ensemble.axis = "T"
207
- elif axis_option == "time":
208
- tsize = len(time)
209
- outnc.createDimension("time", tsize)
210
- primary_axis = "time"
211
- time_var = outnc.createVariable("time", "i4", ("time",))
212
- time_var.axis = "T"
213
- time_var.units = t0
214
- time_var.long_name = "time"
215
-
216
- # Convert time_data to numerical format
217
- nctime = pd2nctime(time, t0)
218
- time_var[:] = nctime
219
-
220
- else:
221
- raise ValueError(f"Invalid axis_option: {axis_option}.")
166
+ outnc.createDimension("ensemble", None)
222
167
 
223
168
  # Variables
169
+ # Dimension Variables
170
+ ensemble = outnc.createVariable("ensemble", "i4", ("ensemble",))
171
+ ensemble.axis = "T"
224
172
 
225
173
  vlead = rd.VariableLeader(infile)
226
174
  vdict = vlead.vleader
@@ -231,17 +179,16 @@ def vlead_nc(
231
179
  for key, values in vdict.items():
232
180
  format_item = key.replace(" ", "_")
233
181
  varid[i] = outnc.createVariable(
234
- format_item, "i4", primary_axis, fill_value=-32768
182
+ format_item, "i4", "ensemble", fill_value=-32768
235
183
  )
236
184
  var = values
237
185
  vshape = var.shape
238
186
  if i == 0:
239
- if primary_axis == "ensemble":
240
- ensemble[:] = np.arange(1, vshape[0] + 1, 1)
187
+ ensemble[:] = np.arange(1, vshape[0] + 1, 1)
241
188
 
242
189
  varid[i][0 : vshape[0]] = var
243
190
  i += 1
244
-
191
+
245
192
  # Add global attributes if provided
246
193
  if attributes:
247
194
  for key, value in attributes.items():
@@ -250,9 +197,7 @@ def vlead_nc(
250
197
  outnc.close()
251
198
 
252
199
 
253
- def finalnc(
254
- outfile, depth, final_mask, time, data, t0="hours since 2000-01-01", attributes=None
255
- ):
200
+ def finalnc(outfile, depth, time, data, t0="hours since 2000-01-01", attributes=None):
256
201
  """
257
202
  Function to create the processed NetCDF file.
258
203
 
@@ -263,21 +208,6 @@ def finalnc(
263
208
  data (numpy array): Velocity (beam, depth, time)
264
209
  t0 (string): Time unit and origin
265
210
  """
266
- fill = -32768
267
-
268
- # Change velocity to cm/s
269
- data = data.astype(np.float64)
270
- data[data > fill] /= 10
271
-
272
- # Change depth to positive
273
- # depth = abs(depth)
274
-
275
- # Reverse the arrays if depth in descending order
276
- if np.all(depth[:-1] >= depth[1:]):
277
- depth = depth[::-1]
278
- data = data[:, ::-1, :]
279
- final_mask = final_mask[::-1, :]
280
-
281
211
  ncfile = nc4.Dataset(outfile, mode="w", format="NETCDF4")
282
212
  # Check if depth is scalar or array
283
213
  if np.isscalar(depth):
@@ -291,22 +221,21 @@ def finalnc(
291
221
  z = ncfile.createVariable("depth", np.float32, ("depth"))
292
222
  z.units = "m"
293
223
  z.long_name = "depth"
294
- z.positive = "down"
295
224
 
296
225
  t = ncfile.createVariable("time", np.float32, ("time"))
297
226
  t.units = t0
298
227
  t.long_name = "time"
299
228
 
300
229
  # Create 2D variables
301
- uvel = ncfile.createVariable("u", np.float32, ("time", "depth"), fill_value=fill)
230
+ uvel = ncfile.createVariable("u", np.float32, ("time", "depth"), fill_value=-32768)
302
231
  uvel.units = "cm/s"
303
232
  uvel.long_name = "zonal_velocity"
304
233
 
305
- vvel = ncfile.createVariable("v", np.float32, ("time", "depth"), fill_value=fill)
234
+ vvel = ncfile.createVariable("v", np.float32, ("time", "depth"), fill_value=-32768)
306
235
  vvel.units = "cm/s"
307
236
  vvel.long_name = "meridional_velocity"
308
237
 
309
- wvel = ncfile.createVariable("w", np.float32, ("time", "depth"), fill_value=fill)
238
+ wvel = ncfile.createVariable("w", np.float32, ("time", "depth"), fill_value=-32768)
310
239
  wvel.units = "cm/s"
311
240
  wvel.long_name = "vertical_velocity"
312
241
 
@@ -316,24 +245,18 @@ def finalnc(
316
245
  evel.units = "cm/s"
317
246
  evel.long_name = "error_velocity"
318
247
 
319
- mvel = ncfile.createVariable("mask", np.float32, ("time", "depth"), fill_value=fill)
320
- mvel.long_name = "Velocity Mask (1: bad value, 0: good value)"
321
-
322
248
  nctime = pd2nctime(time, t0)
323
249
  # write data
324
- z[:] = depth
250
+ z[:] = depth * -1
325
251
  t[:] = nctime
326
252
  uvel[:, :] = data[0, :, :].T
327
253
  vvel[:, :] = data[1, :, :].T
328
254
  wvel[:, :] = data[2, :, :].T
329
255
  evel[:, :] = data[3, :, :].T
330
- mvel[:, :] = final_mask.T
331
-
256
+
332
257
  # Add global attributes if provided
333
258
  if attributes:
334
259
  for key, value in attributes.items():
335
260
  setattr(ncfile, key, str(value)) # Store attributes as strings
336
261
 
337
- ncfile.mask_applied = "True"
338
-
339
262
  ncfile.close()
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.1
2
2
  Name: pyadps
3
- Version: 0.1.0
3
+ Version: 0.1.0b0
4
4
  Summary: A Python package for ADCP data processing
5
5
  Home-page: https://example.com
6
6
  License: MIT
@@ -12,7 +12,6 @@ Classifier: License :: OSI Approved :: MIT License
12
12
  Classifier: Operating System :: OS Independent
13
13
  Classifier: Programming Language :: Python :: 3
14
14
  Classifier: Programming Language :: Python :: 3.12
15
- Classifier: Programming Language :: Python :: 3.13
16
15
  Provides-Extra: tests
17
16
  Requires-Dist: cmake (>=3.30.2)
18
17
  Requires-Dist: matplotlib (>=3.8.4)
@@ -22,30 +21,18 @@ Requires-Dist: numpy (>=1.26.4)
22
21
  Requires-Dist: pandas (>=2.2.2)
23
22
  Requires-Dist: plotly (>=5.22.0)
24
23
  Requires-Dist: plotly-resampler (>=0.10.0)
25
- Requires-Dist: pygeomag (>=1.1.0,<2.0.0)
26
24
  Requires-Dist: scipy (>=1.14.0)
27
25
  Requires-Dist: streamlit (>=1.36.0)
26
+ Requires-Dist: wmm2020 (>=1.1.1)
28
27
  Project-URL: Documentation, https://example.com/docs
29
28
  Project-URL: Repository, https://github.com/p-amol/pyadps
30
29
  Description-Content-Type: text/markdown
31
30
 
32
31
  # pyadps
33
32
 
34
- `pyadps` is a Python package for processing moored Acoustic Doppler
35
- Current Profiler (ADCP) data. It provides various functionalities
36
- such as data reading, quality control tests, NetCDF file creation,
37
- and visualization.
33
+ `pyadps` is a Python package for processing moored Acoustic Doppler Current Profiler (ADCP) data. It provides various functionalities such as data reading, quality control tests, NetCDF file creation, and visualization.
38
34
 
39
- This software offers both a graphical interface (`Streamlit`) for
40
- those new to Python and direct Python package access for experienced
41
- users. Please note that `pyadps` is primarily designed for Teledyne
42
- RDI workhorse ADCPs. Other company's ADCP files are not compatible,
43
- and while some other RDI models may work, they might require additional
44
- considerations.
45
-
46
- - Documentation: <https://pyadps.readthedocs.io>
47
- - Source code: <https://github.com/p-amol/pyadps>
48
- - Bug reports: <https://github.com/p-amol/pyadps/issues>
35
+ This software offers both a graphical interface (`Streamlit`) for those new to Python and direct Python package access for experienced users. Please note that `pyadps` is primarily designed for Teledyne RDI workhorse ADCPs. Other company's ADCP files are not compatible, and while some other RDI models may work, they might require additional considerations.
49
36
 
50
37
  ## Table of Contents
51
38
 
@@ -55,49 +42,37 @@ considerations.
55
42
 
56
43
  ## Installation
57
44
 
58
- We recommend installing the package within a virtual environment.
59
- At present, the package is compatible exclusively with Python version 3.12.
60
- You can create a Python environment using tools like `venv` or `conda`.
61
- Below are instructions for both methods.
45
+ We recommend installing the package within a virtual environment. At present, the package is compatible exclusively with Python version 3.12.
46
+ You can create a Python environment using tools like `venv` or `conda`. Below are instructions for both methods.
62
47
 
63
48
  ### 1. Using `venv` (Built-in Python Tool)
64
49
 
65
50
  #### Step 1: Install Python version 3.12 (if not already installed)
66
-
67
51
  Ensure you have Python installed. You can download the latest version from [python.org](https://www.python.org/downloads/).
68
52
 
69
- #### Step 2: Create a Virtual Environment
70
-
53
+ #### Step 2: Create a Virtual Environment
71
54
  - Open your terminal or command prompt.
72
55
  - Navigate to your project folder:
73
-
74
56
  ```bash
75
57
  cd /path/to/your/project
76
58
  ```
77
-
78
- - Run the following command to create a virtual environment
79
- (replace adpsenv with your preferred environment name):
59
+ - Run the following command to create a virtual environment (replace adpsenv with your preferred environment name):
80
60
 
81
61
  ```bash
82
62
  python -m venv adpsenv
83
63
  ```
84
64
 
85
65
  #### Step 3: Activate the Environment
86
-
87
66
  - On Windows:
88
-
89
67
  ```bash
90
68
  adpsenv\Scripts\activate
91
69
  ```
92
70
 
93
71
  - On macOS/Linux:
94
-
95
72
  ```bash
96
73
  source adpsenv/bin/activate
97
74
  ```
98
-
99
- You’ll see the environment name in your terminal prompt
100
- indicating the environment is active.
75
+ You’ll see the environment name in your terminal prompt indicating the environment is active.
101
76
 
102
77
  #### Step 4: Install Dependencies
103
78
 
@@ -108,51 +83,44 @@ pip install pyadps
108
83
  ```
109
84
 
110
85
  #### Step 5: Deactivate the Environment
111
-
112
86
  When you’re done working in the environment, deactivate it by running:
113
87
 
114
88
  ```bash
115
89
  deactivate
116
90
  ```
117
91
 
118
- ### 2. Using `conda` (Anaconda/Miniconda)
119
92
 
120
- #### Step 1: Install Conda
121
93
 
94
+
95
+ ### 2. Using `conda` (Anaconda/Miniconda):
96
+
97
+ #### Step 1: Install Conda
122
98
  First, you need to have Conda installed on your system. You can either install:
123
99
 
124
100
  - [Anaconda (Full Distribution)](https://www.anaconda.com/products/individual)
125
101
  - [Miniconda (Lightweight Version)](https://docs.conda.io/en/latest/miniconda.html)
126
102
 
127
103
  #### Step 2: Create a Conda Environment with Python 3.12
128
-
129
- Once Conda is installed, open a terminal or command prompt and run
130
- the following to create a new environment (replace `adpsenv` with
131
- your preferred environment name):
104
+ Once Conda is installed, open a terminal or command prompt and run the following to create a new environment (replace `adpsenv` with your preferred environment name):
132
105
 
133
106
  ```bash
134
107
  conda create --name adpsenv python=3.12
135
108
  ```
136
109
 
137
- #### Step 3: Activate the Conda Environment
138
-
110
+ #### Step 3: Activate the Environment
139
111
  ```bash
140
112
  conda activate adpsenv
141
113
  ```
142
114
 
143
- #### Step 4: Install pyadps Dependencies
144
-
145
- You can install packages with pip inside Conda environments.
146
-
115
+ #### Step 4: Install Dependencies
116
+ You can install packages with pip inside Conda environments.
147
117
  ```bash
148
118
  pip install pyadps
149
119
  ```
150
120
 
151
- #### Step 5: Deactivate the Conda Environment
152
-
153
- When done working in the environment, deactivate the environment by running:
154
-
155
- ```bash
121
+ #### Step 5: Deactivate the Environment
122
+ When done, deactivate the environment by running:
123
+ ```
156
124
  conda deactivate
157
125
  ```
158
126
 
@@ -161,11 +129,11 @@ conda deactivate
161
129
  ### Streamlit web interface
162
130
 
163
131
  Open a terminal or command prompt, activate the environment, and run the command.
164
-
165
132
  ```bash
166
133
  run-pyadps
167
134
  ```
168
135
 
136
+
169
137
  ## License
170
138
 
171
139
  This project is licensed under the MIT License. See the LICENSE file for details.
@@ -0,0 +1,29 @@
1
+ pyadps/Home_Page.py,sha256=gC0eFMtn85U_A4KcVlCEzXkB6a_J0WD3vpK691Kmyw8,1180
2
+ pyadps/__init__.py,sha256=bNCm6_WIhiwvaUeOZhRkyLZyzzUKfSH80Fslg0JPJyk,232
3
+ pyadps/__main__.py,sha256=cIFUayxPnKl00oIR99L6IUEvc8trW7dijtfBQCAen5c,356
4
+ pyadps/pages/01_Read_File.py,sha256=ndBslgOHxbk6U6AMKL2uEnwCFL7rukpx8CqfM-_LXz8,8788
5
+ pyadps/pages/02_View_Raw_Data.py,sha256=-Txl4seQG_c1iAyKRDGONebOARmgEelTgYw19DajToo,3675
6
+ pyadps/pages/03_Download_Raw_File.py,sha256=YdGnlx6ZsJ_vAEK8086sCIHewvi9gg0d2yWl7s7qeNU,8216
7
+ pyadps/pages/04_QC_Test.py,sha256=uawHLN9X7X7ykOZtI_viMMG-OlEEerm2X8uJFyWiRzo,8363
8
+ pyadps/pages/05_Profile_Test.py,sha256=wQ_jXaaaEPCdb4yWzITHuGlkbGdw97ZnlK_4ppF7XS4,12114
9
+ pyadps/pages/06_Velocity_Test.py,sha256=8AtUC3V7BJPuxVe1gMkrdwG0_XZwE0DE4bRCW86Luto,9666
10
+ pyadps/pages/07_Write_File.py,sha256=7SBx4IDV4Oi6CBPvTzV7dJCvjGOimr6FwSEksk_rQBk,13481
11
+ pyadps/pages/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ pyadps/utils/__init__.py,sha256=EyjpjGiv-IEL7Q09pBvVJ6O7rnRyUdb1dkNlOFTn_xQ,362
13
+ pyadps/utils/cutbin.py,sha256=JioME3mo4wZKiJ7lOWqNo0MvxHNFYv2enirBoD0oh6E,15911
14
+ pyadps/utils/metadata/flmeta.json,sha256=diIB9nht_0uw9YJNSFGdZYGzeVbR-07zIZS9Nf4VPSE,14245
15
+ pyadps/utils/metadata/vlmeta.json,sha256=_dkQlGkkUvpAIM7S6kEUenSaiCpOrwXg8n1aU3dDF3s,22535
16
+ pyadps/utils/plotgen.py,sha256=ylYPxBmrtPc_ssgEwyUixc6p3QuNcTs88LgJHWk_Vag,7129
17
+ pyadps/utils/profile_test.py,sha256=1Ot8_1z9VUfX4bmVp-_P_QStrnbkVDwLth2pQQCJTrM,5652
18
+ pyadps/utils/pyreadrdi.py,sha256=MX5xe5qKwFMF1RWeCQ3-vBDxm9nP0UbHsEJzSDewnuY,34807
19
+ pyadps/utils/readrdi.py,sha256=jRtzMsaAd_raDD5fmAjVXK5M18QgukmW7SmmACI98o0,44975
20
+ pyadps/utils/regrid.py,sha256=Oh1s4g83EWOvCfOkFiEpNoEI3ARwMukjlmVCi834KYM,3269
21
+ pyadps/utils/script.py,sha256=yf3AZS3FMS2xk77rwezGA8WefwV03vIRQ6HraoeLuBA,4965
22
+ pyadps/utils/signal_quality.py,sha256=E1lZWZfdUnbc5c02px5WWU8b12DnkeCo-gRHjIoe18s,4170
23
+ pyadps/utils/velocity_test.py,sha256=keNd2DNBF0E0FhkqGHXM-zapA5xCEvvh8eyBd3xacvU,3555
24
+ pyadps/utils/writenc.py,sha256=fJi7KSUS5AqZt-YNVsfM74Q0Dq54FUiPyMkNFRc83MQ,7663
25
+ pyadps-0.1.0b0.dist-info/LICENSE,sha256=sfY_7DzQF5FxnO2T6ek74dfm5uBmwEp1oEg_WlzNsb8,1092
26
+ pyadps-0.1.0b0.dist-info/METADATA,sha256=EYXVTygVzbyau6IJ4ro7iWq0Yv_3YobAO4KPoNeQp4c,4187
27
+ pyadps-0.1.0b0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
28
+ pyadps-0.1.0b0.dist-info/entry_points.txt,sha256=jFrXjOakSOPFOv2iDeYx_fI9FxdL1wXQ6FghECFpsvg,51
29
+ pyadps-0.1.0b0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.0.0
2
+ Generator: poetry-core 1.9.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ run-pyadps=pyadps.__main__:main
3
+