1313# limitations under the License.
1414"""Data loaders for tabular data stored in Parquet format."""
1515
16+ from collections .abc import Hashable
1617import functools
1718import os
18- from typing import Callable , Hashable , Mapping , Optional , Sequence , Union
19+ from typing import Callable , Mapping , Optional , Sequence , Union
1920import numpy as np
2021import pandas as pd
2122import pyarrow
22- from weatherbenchX import interpolations
2323from weatherbenchX .data_loaders import base
2424import xarray as xr
2525
@@ -91,7 +91,6 @@ def __init__(
9191 coordinate_variables : Sequence [str ] = (),
9292 split_variables : bool = False ,
9393 dropna : bool = False ,
94- add_nan_mask : bool = False ,
9594 tolerance : Optional [
9695 np .timedelta64 | tuple [np .timedelta64 , np .timedelta64 ]
9796 ] = None ,
@@ -102,8 +101,7 @@ def __init__(
102101 observation_dim : Optional [str ] = None ,
103102 file_tolerance : np .timedelta64 = np .timedelta64 (1 , 'h' ),
104103 preprocessing_fn : Optional [Callable [[pd .DataFrame ], pd .DataFrame ]] = None ,
105- interpolation : Optional [interpolations .Interpolation ] = None ,
106- process_chunk_fn : Optional [Callable [[xr .Dataset ], xr .Dataset ]] = None ,
104+ ** kwargs ,
107105 ):
108106 """Init.
109107
@@ -123,10 +121,6 @@ def __init__(
123121 dropna: Whether to drop missing values. If split_variables is True, values
124122 will be dropped for each variable separately. Otherwise, only indices
125123 where all variables are non-NaN will be returned.
126- add_nan_mask: Adds a boolean coordinate named 'mask' to each variable
127- (variables will be split into DataArrays if they aren't already), with
128- False indicating NaN values. To be used for masked aggregation. Default:
129- False.
130124 tolerance: (Optional) Tolerance around the given valid time. If tolerance
131125 is a single timedelta, data within valid_time +/- tolerance will be
132126 returned. If tolerance is a 2-tuple of timedeltas, data within
@@ -153,16 +147,12 @@ def __init__(
153147 1h
154148 preprocessing_fn: (Optional) Function to apply to the dataframe after
155149 reading.
156- interpolation: (Optional) Interpolation to be applied to the data.
157- process_chunk_fn: (Optional) Function to apply to the chunk of data after
158- loading.
150+ **kwargs: Additional keyword arguments passed to the base DataLoader.
159151 """
160152
161153 super ().__init__ (
162- interpolation = interpolation ,
163154 compute = False , # Data is already loaded.
164- add_nan_mask = add_nan_mask ,
165- process_chunk_fn = process_chunk_fn ,
155+ ** kwargs
166156 )
167157 self ._path = path
168158 if partitioned_by not in ['hour' , 'day' , 'month' ]:
@@ -479,7 +469,6 @@ def __init__(
479469 time_dim : str ,
480470 split_variables : bool = False ,
481471 dropna : bool = False ,
482- add_nan_mask : bool = False ,
483472 tolerance : Optional [np .timedelta64 ] = None ,
484473 partitioned_by : str = 'month' ,
485474 rename_variables : Optional [Mapping [str , str ]] = None ,
@@ -488,8 +477,7 @@ def __init__(
488477 pick_closest_duplicate_by : Optional [str ] = None ,
489478 file_tolerance : np .timedelta64 = np .timedelta64 (1 , 'h' ),
490479 preprocessing_fn : Optional [Callable [[pd .DataFrame ], pd .DataFrame ]] = None ,
491- interpolation : Optional [interpolations .Interpolation ] = None ,
492- process_chunk_fn : Optional [Callable [[xr .Dataset ], xr .Dataset ]] = None ,
480+ ** kwargs ,
493481 ):
494482 def metar_preprocessing_fn (
495483 df : pd .DataFrame ,
@@ -521,7 +509,6 @@ def metar_preprocessing_fn(
521509 observation_dim = 'stationName' ,
522510 split_variables = split_variables ,
523511 dropna = dropna ,
524- add_nan_mask = add_nan_mask ,
525512 tolerance = tolerance ,
526513 partitioned_by = partitioned_by ,
527514 rename_variables = METAR_TO_ERA5_NAMES ,
@@ -532,6 +519,5 @@ def metar_preprocessing_fn(
532519 preprocessing_fn = functools .partial (
533520 metar_preprocessing_fn , preprocessing_fn = preprocessing_fn
534521 ),
535- interpolation = interpolation ,
536- process_chunk_fn = process_chunk_fn ,
522+ ** kwargs ,
537523 )
0 commit comments