Skip to content

CAMELS-IND

Overview

CAMELS-IND is the India hydrological dataset implementation. Indian CAMELS dataset with monsoon-influenced catchments.

Dataset Information

  • Region: India
  • Module: hydrodataset.camels_ind
  • Class: CamelsInd

Features

Static Attributes

Static catchment attributes include: - Basin area - Mean precipitation - Topographic characteristics - Land cover information - Soil properties - Climate indices

Dynamic Variables

Timeseries variables available (varies by dataset): - Streamflow - Precipitation - Temperature (min, max, mean) - Potential evapotranspiration - Solar radiation - And more...

Usage

Basic Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from hydrodataset.camels_ind import CamelsInd
from hydrodataset import SETTING

# Initialize dataset
data_path = SETTING["local_data_path"]["datasets-origin"]
ds = CamelsInd(data_path)

# Get basin IDs
basin_ids = ds.read_object_ids()
print(f"Number of basins: {len(basin_ids)}")

# Check available features
print("Static features:", ds.available_static_features)
print("Dynamic features:", ds.available_dynamic_features)

# Read timeseries data
timeseries = ds.read_ts_xrdataset(
    gage_id_lst=basin_ids[:5],
    t_range=ds.default_t_range,
    var_lst=["streamflow", "precipitation"]
)
print(timeseries)

# Read attribute data
attributes = ds.read_attr_xrdataset(
    gage_id_lst=basin_ids[:5],
    var_lst=["area", "p_mean"]
)
print(attributes)

Reading Specific Variables

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Read with specific time range
ts_data = ds.read_ts_xrdataset(
    gage_id_lst=basin_ids[:10],
    t_range=["1990-01-01", "1995-12-31"],
    var_lst=["streamflow", "precipitation", "temperature_mean"]
)

# Read basin area
areas = ds.read_area(gage_id_lst=basin_ids[:10])

# Read mean precipitation
mean_precip = ds.read_mean_prcp(gage_id_lst=basin_ids[:10])

Data Sources

The dataset supports multiple data sources for certain variables. Check the class documentation for available sources and use tuple notation to specify:

1
2
3
4
5
6
7
8
9
# Request specific data source
ts_data = ds.read_ts_xrdataset(
    gage_id_lst=basin_ids[:5],
    t_range=["1990-01-01", "1995-12-31"],
    var_lst=[
        ("precipitation", "era5land"),  # Specify ERA5-Land source
        "streamflow"  # Use default source
    ]
)

API Reference

hydrodataset.camels_ind.CamelsInd

Bases: HydroDataset

CAMELS_IND dataset class extending HydroDataset.

This class provides access to the CAMELS_IND dataset, which contains hydrological and meteorological data for various watersheds in India. It uses a custom implementation to support the latest dataset version.

The class relies on AquaFetch for data reading but overrides certain methods to support the new file structure in the latest Zenodo release.

Attributes:

Name Type Description
region

Geographic region identifier

download

Whether to download data automatically

aqua_fetch

CustomCAMELS_IND instance for data access

Source code in hydrodataset/camels_ind.py
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
class CamelsInd(HydroDataset):
    """CAMELS_IND dataset class extending HydroDataset.

    This class provides access to the CAMELS_IND dataset, which contains
    hydrological and meteorological data for various watersheds in India.
    It uses a custom implementation to support the latest dataset version.

    The class relies on AquaFetch for data reading but overrides certain
    methods to support the new file structure in the latest Zenodo release.

    Attributes:
        region: Geographic region identifier
        download: Whether to download data automatically
        aqua_fetch: CustomCAMELS_IND instance for data access
    """

    def __init__(
        self, data_path: str, region: Optional[str] = None, download: bool = False
    ) -> None:
        """Initialize CAMELS_IND dataset.

        Args:
            data_path: Path to the CAMELS_IND data directory
            region: Geographic region identifier (optional)
            download: Whether to download data automatically (default: False)
        """
        super().__init__(data_path)
        self.region = region
        self.download = download

        try:
            # Use custom class that supports the latest dataset version
            self.aqua_fetch = CustomCAMELS_IND(data_path)
        except Exception as e:
            print(e)
            # If initialization fails, try to extract zip files
            check_zip_extract = False
            zip_files = [
                "CAMELS_IND_All_Catchments.zip",
                "CAMELS_IND_Catchments_Streamflow_Sufficient.zip",
            ]
            for filename in tqdm(zip_files, desc="Checking zip files"):
                extracted_dir = self.data_source_dir.joinpath(
                    "CAMELS_IND", filename[:-4]
                )
                if not extracted_dir.exists():
                    check_zip_extract = True
                    break
            if check_zip_extract:
                hydro_file.zip_extract(self.data_source_dir.joinpath("CAMELS_IND"))
            # Retry initialization after extraction
            self.aqua_fetch = CustomCAMELS_IND(data_path)

    @property
    def _attributes_cache_filename(self):
        return "camels_ind_attributes.nc"

    @property
    def _timeseries_cache_filename(self):
        return "camels_ind_timeseries.nc"

    @property
    def default_t_range(self):
        return ["1980-01-01", "2020-12-31"]

    # get the information of features from dataset file"00_CAMELS_IND_Data_Description.pdf"
    _subclass_static_definitions = {
        "p_mean": {"specific_name": "p_mean", "unit": "mm/day"},
        "area": {"specific_name": "area_km2", "unit": "km^2"},
    }

    _dynamic_variable_mapping = {
        StandardVariable.STREAMFLOW: {
            "default_source": "obs",
            "sources": {"obs": {"specific_name": "q_cms_obs", "unit": "m^3/s"}},
        },
        StandardVariable.PRECIPITATION: {
            "default_source": "imd",
            "sources": {"imd": {"specific_name": "pcp_mm", "unit": "mm/day"}},
        },
        StandardVariable.TEMPERATURE_MAX: {
            "default_source": "imd",
            "sources": {"imd": {"specific_name": "airtemp_c_max", "unit": "°C"}},
        },
        StandardVariable.TEMPERATURE_MIN: {
            "default_source": "imd",
            "sources": {"imd": {"specific_name": "airtemp_c_min", "unit": "°C"}},
        },
        StandardVariable.TEMPERATURE_MEAN: {
            "default_source": "imd",
            "sources": {"imd": {"specific_name": "airtemp_c_mean", "unit": "°C"}},
        },
        StandardVariable.SOLAR_RADIATION: {
            "default_source": "imdaa",
            "sources": {"imdaa": {"specific_name": "solrad_wm2", "unit": "W/m^2"}},
        },
        StandardVariable.LONGWAVE_SOLAR_RADIATION: {
            "default_source": "imdaa",
            "sources": {"imdaa": {"specific_name": "lwdownrad_wm2", "unit": "W/m^2"}},
        },
        StandardVariable.WIND_SPEED: {
            "default_source": "imdaa",
            "sources": {"imdaa": {"specific_name": "windspeed_mps", "unit": "m/s"}},
        },
        StandardVariable.V_WIND_SPEED: {
            "default_source": "imdaa",
            "sources": {"imdaa": {"specific_name": "windspeedv_mps", "unit": "m/s"}},
        },
        StandardVariable.U_WIND_SPEED: {
            "default_source": "imdaa",
            "sources": {"imdaa": {"specific_name": "windspeedu_mps", "unit": "m/s"}},
        },
        StandardVariable.RELATIVE_HUMIDITY: {
            "default_source": "imdaa",
            "sources": {"imdaa": {"specific_name": "rh_", "unit": "%"}},
        },
        StandardVariable.POTENTIAL_EVAPOTRANSPIRATION: {
            "default_source": "default",
            "sources": {
                "default": {"specific_name": "pet_mm", "unit": "mm/day"},
                "gleam": {"specific_name": "pet_mm_gleam", "unit": "mm/day"},
            },
        },
        StandardVariable.EVAPOTRANSPIRATION: {
            "default_source": "gleam",
            "sources": {"gleam": {"specific_name": "aet_mm_gleam", "unit": "mm/day"}},
        },
        StandardVariable.EVAPORATION: {
            "default_source": "canopy",
            "sources": {
                "canopy": {"specific_name": "evap_canopy", "unit": "mm/day"},
                "surface": {"specific_name": "evap_surface", "unit": "mm/day"},
            },
        },
        StandardVariable.VOLUMETRIC_SOIL_WATER_LAYER1: {
            "default_source": "imdaa",
            "sources": {"imdaa": {"specific_name": "sm_lvl1", "unit": "kg/m^2"}},
        },
        StandardVariable.VOLUMETRIC_SOIL_WATER_LAYER2: {
            "default_source": "imdaa",
            "sources": {"imdaa": {"specific_name": "sm_lvl2", "unit": "kg/m^2"}},
        },
        StandardVariable.VOLUMETRIC_SOIL_WATER_LAYER3: {
            "default_source": "imdaa",
            "sources": {"imdaa": {"specific_name": "sm_lvl3", "unit": "kg/m^2"}},
        },
        StandardVariable.VOLUMETRIC_SOIL_WATER_LAYER4: {
            "default_source": "imdaa",
            "sources": {"imdaa": {"specific_name": "sm_lvl4", "unit": "kg/m^2"}},
        },
    }

default_t_range property

__init__(data_path, region=None, download=False)

Initialize CAMELS_IND dataset.

Parameters:

Name Type Description Default
data_path str

Path to the CAMELS_IND data directory

required
region Optional[str]

Geographic region identifier (optional)

None
download bool

Whether to download data automatically (default: False)

False
Source code in hydrodataset/camels_ind.py
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
def __init__(
    self, data_path: str, region: Optional[str] = None, download: bool = False
) -> None:
    """Initialize CAMELS_IND dataset.

    Args:
        data_path: Path to the CAMELS_IND data directory
        region: Geographic region identifier (optional)
        download: Whether to download data automatically (default: False)
    """
    super().__init__(data_path)
    self.region = region
    self.download = download

    try:
        # Use custom class that supports the latest dataset version
        self.aqua_fetch = CustomCAMELS_IND(data_path)
    except Exception as e:
        print(e)
        # If initialization fails, try to extract zip files
        check_zip_extract = False
        zip_files = [
            "CAMELS_IND_All_Catchments.zip",
            "CAMELS_IND_Catchments_Streamflow_Sufficient.zip",
        ]
        for filename in tqdm(zip_files, desc="Checking zip files"):
            extracted_dir = self.data_source_dir.joinpath(
                "CAMELS_IND", filename[:-4]
            )
            if not extracted_dir.exists():
                check_zip_extract = True
                break
        if check_zip_extract:
            hydro_file.zip_extract(self.data_source_dir.joinpath("CAMELS_IND"))
        # Retry initialization after extraction
        self.aqua_fetch = CustomCAMELS_IND(data_path)