Skip to content

Commit

Permalink
debugging local console error
Browse files Browse the repository at this point in the history
  • Loading branch information
SammyAgrawal committed Jun 27, 2024
1 parent e2b44ad commit f738543
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
23 changes: 20 additions & 3 deletions feedstock/eNATL60.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""
...
"""
import logging
import xarray as xr
import apache_beam as beam
from pangeo_forge_recipes.patterns import pattern_from_file_sequence
from pangeo_forge_recipes.transforms import (
Expand All @@ -11,6 +13,8 @@
T,
)

logger = logging.getLogger(__name__)

# Common Parameters
days = range(1, 32)
dataset_url = 'https://zenodo.org/records/10513552/files'
Expand All @@ -25,11 +29,24 @@ class Preprocess(beam.PTransform):
@staticmethod
def _set_coords(item: Indexed[T]) -> Indexed[T]:
index, ds = item
ds = ds.set_coords(['deptht', 'depthw', 'nav_lon', 'nav_lat', 'time_counter', 'tmask'])
logger.info(f"Index is {index=}")
logger.info(f"Dataset before processing {ds=}")
logger.info(f"Time counter data : {ds.time_counter.data}")
# could try using cftime to force
# create t_new as variable
t_new = xr.DataArray(ds.time_counter.data, dims=['time'])
logger.info(f"New Time Dimension {t_new=}")
ds = ds.assign_coords(time=t_new)
ds = ds.drop(['time_counter'])
ds = ds.set_coords(['deptht', 'depthw', 'nav_lon', 'nav_lat', 'tmask'])

return index, ds

# ds = ds.set_coords(['deptht', 'depthw', 'nav_lon', 'nav_lat', 'time_counter', 'tmask'])
# ds = ds.assign_coords(
# tmask=ds.coords['tmask'].squeeze(), deptht=ds.coords['deptht'].squeeze()
# )
return index, ds


def expand(self, pcoll: beam.PCollection) -> beam.PCollection:
return pcoll | 'Set coordinates' >> beam.Map(self._set_coords)
Expand All @@ -38,7 +55,7 @@ def expand(self, pcoll: beam.PCollection) -> beam.PCollection:
eNATL60_BLBT02 = (
beam.Create(pattern.items())
| OpenURLWithFSSpec()
| OpenWithXarray()
| OpenWithXarray(xarray_open_kwargs = {'use_cftime':True})
| Preprocess()
| StoreToZarr(
store_name='eNATL60_BLBT02.zarr',
Expand Down
1 change: 1 addition & 0 deletions feedstock/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ pangeo-forge-recipes==0.10.4
gcsfs
apache-beam[gcp]
leap-data-management-utils==0.0.12
xarray=2024.05.0

0 comments on commit f738543

Please sign in to comment.