From ecaa1e1c76974a555feaa17f38695107d135787a Mon Sep 17 00:00:00 2001 From: shaunwbell Date: Tue, 6 Feb 2024 17:10:34 -0800 Subject: [PATCH] Delete src/ecofocipy directory --- src/ecofocipy/io/prooceanus_parser.py | 64 -------------- src/ecofocipy/math/aandopt_oxy_corr.py | 111 ------------------------- src/ecofocipy/math/haversine.py | 45 ---------- 3 files changed, 220 deletions(-) delete mode 100644 src/ecofocipy/io/prooceanus_parser.py delete mode 100644 src/ecofocipy/math/aandopt_oxy_corr.py delete mode 100644 src/ecofocipy/math/haversine.py diff --git a/src/ecofocipy/io/prooceanus_parser.py b/src/ecofocipy/io/prooceanus_parser.py deleted file mode 100644 index 5671882..0000000 --- a/src/ecofocipy/io/prooceanus_parser.py +++ /dev/null @@ -1,64 +0,0 @@ -# EcoFOCI -"""Contains a collection of pro-oceanus equipment parsing. -(A seabird product now) - -These include: - -TDGP - moored - -Non-moored: -* processing is likely the same if recording internally. - -""" -import pandas as pd - - -class tdgp(object): - r""" TDGP (Total Dissolved Gas Pressure) Unified parser - - """ - def __init__(self): - """data is a pandas dataframe - Wich is immediatly converted to xarray - """ - pass - - def parse(self, filename=None, return_header=True, datetime_index=True): - r""" - Basic Method to open and read tdgp txt files - - Format: - Measurement type,Year,Month,Day,Hour,Minute,Second,Pressure sensor temperature,Pressure (mbar),Supply Voltage - - Data (and variable names) are between "File Contents" and "Finished" - """ - - header = [] - fobj = [] - headercount = -2 - with open(filename) as fobj: - for k, line in enumerate(fobj.readlines()): - header = header + [line] - if "File Contents:" in line: - headercount=k - - if (k == headercount+1): - column_names = line.strip().split(',') - break - - - - - rawdata_df = pd.read_csv(filename, - delimiter="\s+|,", - skiprows=headercount+3, names=column_names, skipfooter=12) - - rawdata_df["date_time"] = pd.to_datetime(rawdata_df[['Day','Month','Year','Hour','Minute','Second']] - .astype(str).apply(' '.join, 1), format='%d %m %Y %H %M %S') - - if datetime_index: - rawdata_df = rawdata_df.set_index(pd.DatetimeIndex(rawdata_df['date_time'])).drop(['date_time','Day','Month','Year','Hour','Minute','Second'],axis=1) - - self.rawdata_df = rawdata_df - - return (rawdata_df,header) diff --git a/src/ecofocipy/math/aandopt_oxy_corr.py b/src/ecofocipy/math/aandopt_oxy_corr.py deleted file mode 100644 index c6380a6..0000000 --- a/src/ecofocipy/math/aandopt_oxy_corr.py +++ /dev/null @@ -1,111 +0,0 @@ -""" -aandopt_oxy_corr.py - -Apply Aanderaa Pressure and Salinity Corrections - -Standard FOCI procedure has salinity set to 0PSU for deployment. -This is also the Aanderaa Factory setting. - -""" - -import numpy as np -import seawater as sw - - -def o2_sal_comp(oxygen_conc=None, salinity=None, temperature=None, internal_sal=0.0): - """ - From Aandera April2007 -TD 218 Operating Manual - Oxygen Optodes (pg32) - - oxygen_conc - micromoles/kg - salinity - salinity in ppt - temperature - B,C coefs - - """ - - coefs = { - "B0": -6.24097e-3, - "B1": -6.93498e-3, - "B2": -6.90358e-3, - "B3": -4.29155e-3, - "C0": -3.11680e-7, - } - - scaled_temp = np.log((298.15 - temperature) / (273.15 + temperature)) - - exp_a = salinity - internal_sal - exp_b = ( - coefs["B0"] - + coefs["B1"] * scaled_temp - + coefs["B2"] * scaled_temp ** 2.0 - + coefs["B3"] * scaled_temp ** 3.0 - ) - exp_c = coefs["C0"] * (salinity ** 2.0 - internal_sal ** 2.0) - - return oxygen_conc * np.exp(exp_a * exp_b + exp_c) - - -def o2_dep_comp(oxygen_conc=None, depth=None): - """ - From Aandera Operating Manual - Oxygen Optodes - - Small correction for normal FOCI operations (<500m) but should be used for deep stations - """ - return oxygen_conc * (1.0 + (0.032 * depth) / 1000.0) - - -def o2_percent_sat(oxygen_conc=None, temperature=None, salinity=None, pressure=0): - """ - calculate oxygen saturation - Garcia and Gorden 1992 - from Seabird Derived Parameter Formulas - """ - - coefs = { - "GG_A0": 2.00907, - "GG_A1": 3.22014, - "GG_A2": 4.0501, - "GG_A3": 4.94457, - "GG_A4": -0.256847, - "GG_A5": 3.88767, - "GG_B0": -0.00624523, - "GG_B1": -0.00737614, - "GG_B2": -0.010341, - "GG_B3": -0.00817083, - "GG_C0": -0.000000488682, - } - - scaled_temp = np.log((298.15 - temperature) / (273.15 + temperature)) - - oxsol_pri = np.exp( - coefs["GG_A0"] - + coefs["GG_A1"] * scaled_temp - + coefs["GG_A2"] * (scaled_temp) ** 2 - + coefs["GG_A3"] * (scaled_temp) ** 3 - + coefs["GG_A4"] * (scaled_temp) ** 4 - + coefs["GG_A5"] * (scaled_temp) ** 5 - + salinity - * ( - coefs["GG_B0"] - + coefs["GG_B1"] * scaled_temp - + coefs["GG_B2"] * (scaled_temp) ** 2 - + coefs["GG_B3"] * (scaled_temp) ** 3 - ) - + coefs["GG_C0"] * (salinity) ** 2 - ) - - # determine sigmatheta and convert Oxygen from micromoles/kg to ml/l - # calculate new oxygen saturation percent using derived oxsol - sigmatheta_pri = sw.eos80.pden(salinity, temperature, pressure) - oxy_percent_sat = ((oxygen_conc * sigmatheta_pri / 44660) / oxsol_pri) * 100.0 - - return oxy_percent_sat - - -def o2_molar2umkg(oxygen_conc=None, salinity=None, temperature=None, pressure=None): - """unit conversalinity=Noneion for micromole/liter -> micromole/kg""" - - sigmatheta_pri = sw.eos80.pden(salinity, temperature, pressure) - density = sigmatheta_pri / 1000 - oxygen_conc = oxygen_conc / density - - return oxygen_conc diff --git a/src/ecofocipy/math/haversine.py b/src/ecofocipy/math/haversine.py deleted file mode 100644 index 794711c..0000000 --- a/src/ecofocipy/math/haversine.py +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env python -# Haversine formula example in Python -# Author: Wayne Dyck - -import math - -import numpy as np - - -def distance(origin, destination): - lat1, lon1 = origin - lat2, lon2 = destination - radius = 6371 # km - - dlat = math.radians(lat2-lat1) - dlon = math.radians(lon2-lon1) - a = math.sin(dlat/2) * math.sin(dlat/2) + math.cos(math.radians(lat1)) \ - * math.cos(math.radians(lat2)) * math.sin(dlon/2) * math.sin(dlon/2) - c = 2 * math.atan2(math.sqrt(a), math.sqrt(1-a)) - d = radius * c - - return d - -def nearest_point(origin, latpoints, lonpoints, grid='1d'): - - if grid == '1d': - dist = np.zeros((np.shape(latpoints)[0], np.shape(lonpoints)[0])) - - for i, lat in enumerate(latpoints): - for j, lon in enumerate(lonpoints): - dist[i,j] = distance(origin,[lat,lon]) - - lati, loni = np.where(dist == dist.min()) - return (dist.min(), latpoints[lati[0]], lonpoints[loni[0]], lati[0], loni[0] ) - - elif grid == '2d': - dist = np.zeros_like(latpoints) - - for i, latrow in enumerate(latpoints): - for j, lonrow in enumerate(latrow): - dist[i,j] = distance(origin,[latpoints[i,j],lonpoints[i,j]]) - - lati, loni = np.where(dist == dist.min()) - - return (dist.min(), latpoints[lati[0]][loni[0]], lonpoints[lati[0]][loni[0]], lati[0], loni[0] ) \ No newline at end of file