bluemath_tk.downloaders.noaa package
Submodules
bluemath_tk.downloaders.noaa.noaa_downloader module
- class bluemath_tk.downloaders.noaa.noaa_downloader.NOAADownloader(product: str, base_path_to_download: str, debug: bool = True)[source]
Bases:
BaseDownloaderThis is the main class to download data from NOAA.
Examples
>>> downloader = NOAADownloader( ... product="NDBC", ... base_path_to_download="./noaa_data", ... debug=True ... ) >>> result = downloader.download_data( ... data_type="bulk_parameters", ... buoy_id="41001", ... years=[2023], ... dry_run=False ... ) >>> print(result)
- property data_types: dict
Data types configuration dictionary.
- Returns:
Dictionary of available data types and their configurations.
- Return type:
dict
- download_data(dry_run: bool = True, *args, **kwargs) DownloadResult[source]
Download data for the product.
Routes to product-specific download methods based on the product type.
- Parameters:
dry_run (bool, optional) – If True, only check what would be downloaded without actually downloading. Default is True.
*args – Arguments passed to product-specific download method.
**kwargs – Keyword arguments passed to product-specific download method.
- Returns:
Result with information about downloaded, skipped, and error files.
- Return type:
- Raises:
ValueError – If the product is not supported.
- download_data_ndbc(data_type: str, dry_run: bool = True, **kwargs) DownloadResult[source]
Download data for the NDBC product.
Downloads NDBC buoy data or forecast data based on the specified data type. Files are saved to: base_path_to_download/product/dataset/…
- Parameters:
data_type (str) – The data type to download. Available types: - ‘bulk_parameters’: Standard meteorological data - ‘wave_spectra’: Wave spectral density data - ‘directional_spectra’: Directional wave spectra coefficients - ‘wind_forecast’: GFS wind forecast data
dry_run (bool, optional) – If True, only check what would be downloaded without actually downloading. Default is True.
**kwargs – Additional keyword arguments specific to each data type: - For bulk_parameters, wave_spectra, directional_spectra: buoy_id, years, force - For wind_forecast: date, region, force
- Returns:
Result with information about downloaded, skipped, and error files.
- Return type:
- Raises:
ValueError – If the data type is not supported.
- list_data_types() List[str][source]
List all available data types for the product.
- Returns:
List of available data type names.
- Return type:
List[str]
- property product_config: dict
Product configuration dictionary loaded from config file.
- Returns:
Product configuration dictionary.
- Return type:
dict
- products_configs = {'NDBC': {'data_types': {'bulk_parameters': {'columns': ['YYYY', 'MM', 'DD', 'hh', 'mm', 'WD', 'WSPD', 'GST', 'WVHT', 'DPD', 'APD', 'MWD', 'BAR', 'ATMP', 'WTMP', 'DEWP', 'VIS', 'TIDE'], 'dataset': 'buoy_data', 'description': 'Wind, wave, temperature, and pressure measurements', 'fallback_urls': ['view_text_file.php?filename={buoy_id}h{year}.txt.gz&dir=data/historical/stdmet/', 'stdmet/{year}/{buoy_id}h{year}.txt.gz'], 'file_format': 'txt.gz', 'long_name': 'Standard Meteorological Data', 'name': 'bulk_parameters', 'url_pattern': 'historical/stdmet/{buoy_id}h{year}.txt.gz'}, 'directional_spectra': {'coefficients': {'d': {'name': 'alpha1', 'url_pattern': 'historical/swdir/{buoy_id}d{year}.txt.gz'}, 'i': {'name': 'alpha2', 'url_pattern': 'historical/swdir2/{buoy_id}i{year}.txt.gz'}, 'j': {'name': 'r1', 'url_pattern': 'historical/swr1/{buoy_id}j{year}.txt.gz'}, 'k': {'name': 'r2', 'url_pattern': 'historical/swr2/{buoy_id}k{year}.txt.gz'}, 'w': {'name': 'c11', 'url_pattern': 'historical/swden/{buoy_id}w{year}.txt.gz'}}, 'dataset': 'buoy_data', 'description': 'Fourier coefficients for directional wave spectra', 'file_format': 'txt.gz', 'long_name': 'Directional Wave Spectra Coefficients', 'name': 'directional_spectra'}, 'wave_spectra': {'dataset': 'buoy_data', 'description': 'Wave energy density spectra', 'file_format': 'txt.gz', 'long_name': 'Wave Spectral Density', 'name': 'wave_spectra', 'url_pattern': 'historical/swden/{buoy_id}w{year}.txt.gz'}, 'wind_forecast': {'dataset': 'forecast_data', 'description': 'Wind speed and direction forecast from GFS model', 'file_format': 'netcdf', 'long_name': 'GFS Wind Forecast', 'name': 'wind_forecast', 'output_variables': {'u10': 'ugrd10m', 'v10': 'vgrd10m'}, 'variables': ['ugrd10m', 'vgrd10m']}}, 'datasets': {'buoy_data': {'base_url': 'https://www.ndbc.noaa.gov/data', 'description': 'Historical buoy measurements from NDBC', 'mandatory_fields': ['buoy_id', 'year'], 'name': 'NOAA Buoy Data', 'template': {'buoy_id': None, 'data_type': 'bulk_parameters', 'year': None}}, 'forecast_data': {'base_url': 'https://nomads.ncep.noaa.gov/dods/gfs_0p25_1hr', 'description': 'GFS 0.25 degree forecast data', 'mandatory_fields': ['date'], 'name': 'NOAA GFS Forecast Data', 'template': {'date': None}}}}}
- bluemath_tk.downloaders.noaa.noaa_downloader.read_bulk_parameters(base_path: str, buoy_id: str, years: int | List[int]) DataFrame | None[source]
Read bulk parameters for a specific buoy and year(s).
- Parameters:
base_path (str) – Base path where the data is stored.
buoy_id (str) – The buoy ID.
years (Union[int, List[int]]) – The year(s) to read data for. Can be a single year or a list of years.
- Returns:
DataFrame containing the bulk parameters, or None if data not found.
- Return type:
Optional[pd.DataFrame]
- bluemath_tk.downloaders.noaa.noaa_downloader.read_directional_spectra(base_path: str, buoy_id: str, years: int | List[int]) Tuple[DataFrame | None, ...][source]
Read directional spectra data for a specific buoy and year(s).
- Parameters:
base_path (str) – Base path where the data is stored.
buoy_id (str) – The buoy ID
years (Union[int, List[int]]) – The year(s) to read data for. Can be a single year or a list of years.
- Returns:
Tuple containing DataFrames for alpha1, alpha2, r1, r2, and c11, or None for each if data not found
- Return type:
Tuple[Optional[pd.DataFrame], …]
- bluemath_tk.downloaders.noaa.noaa_downloader.read_wave_spectra(base_path: str, buoy_id: str, years: int | List[int]) DataFrame | None[source]
Read wave spectra data for a specific buoy and year(s).
- Parameters:
base_path (str) – Base path where the data is stored.
buoy_id (str) – The buoy ID.
years (Union[int, List[int]]) – The year(s) to read data for. Can be a single year or a list of years.
- Returns:
DataFrame containing the wave spectra, or None if data not found
- Return type:
Optional[pd.DataFrame]