Skip to content

Commit

Permalink
concatenate sondes
Browse files Browse the repository at this point in the history
  • Loading branch information
hgloeckner committed Aug 19, 2024
1 parent 1d70066 commit e1abfc4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/halodrops/pipeline.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from .helper.paths import Platform, Flight
from .helper.__init__ import platform_path_template, flight_path_template
from .processor import Sonde
from .processor import Sonde, Gridded
import configparser
import inspect
import os
import xarray as xr
import warnings


def get_mandatory_args(function):
Expand Down Expand Up @@ -291,8 +292,12 @@ def rm_no_launch(sondes: dict, config: configparser.ConfigParser):
return sondes


def iterate_method_over_dataset(dataset: xr.Dataset, functions: list) -> xr.Dataset:
pass
def sondes_to_gridded(sondes: dict, config: configparser.ConfigParser):
flight_id = list(sondes.values())[0].flight_id
platform_id = list(sondes.values())[0].platform_id
gridded = Gridded(sondes, flight_id, platform_id)
gridded.concat_sondes()
return gridded


def gridded_to_pattern(
Expand Down Expand Up @@ -448,6 +453,12 @@ def run_pipeline(pipeline: dict, config: configparser.ConfigParser):
"output": "sondes",
"comment": "This step reads from the saved L2 files and prepares individual sonde datasets before they can be concatenated to create L3.",
},
"concatenate_L2": {
"intake": "sondes",
"apply": sondes_to_gridded,
"output": "gridded",
"comment": "This step concatenates the individual sonde datasets to create the L3 dataset.",
},
# "create_patterns": {
# "intake": "gridded",
# "apply": gridded_to_pattern,
Expand Down
16 changes: 16 additions & 0 deletions src/halodrops/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1099,3 +1099,19 @@ def add_q_and_theta_to_l2_ds(self):
object.__setattr__(self, "_interim_l3_ds", ds)

return self


@dataclass(order=True)
class Gridded:
sondes: dict
flight_id: str
platform_id: str

def concat_sondes(self):
"""
function to concatenate all sondes using the combination of all measurement times and launch times
"""
list_of_l2_ds = [sonde._prep_l3_ds for sonde in self.sondes.values()]
combined = xr.combine_by_coords(list_of_l2_ds)
self._interim_l3_ds = combined
return self

0 comments on commit e1abfc4

Please sign in to comment.