varunayan.core module#

class varunayan.core.ProcessingParams(request_id: str, variables: List[str], start_date: datetime.datetime, end_date: datetime.datetime, frequency: str = 'hourly', resolution: float = 0.25, dataset_type: str = 'single', pressure_levels: List[str] | None = None, north: float | None = None, south: float | None = None, east: float | None = None, west: float | None = None, geojson_file: str | None = None, geojson_data: Dict[str, Any] | None = None)[source]#

Bases: object

dataset_type: str = 'single'[source]#
east: float | None = None[source]#
end_date: datetime[source]#
frequency: str = 'hourly'[source]#
geojson_data: Dict[str, Any] | None = None[source]#
geojson_file: str | None = None[source]#
north: float | None = None[source]#
pressure_levels: List[str] | None = None[source]#
request_id: str[source]#
resolution: float = 0.25[source]#
south: float | None = None[source]#
start_date: datetime[source]#
variables: List[str][source]#
west: float | None = None[source]#
varunayan.core.adjust_sum_variables(df: DataFrame, frequency: str) None[source]#

Adjust sum variables based on temporal frequency

varunayan.core.aggregate_and_save(params: ProcessingParams, df: DataFrame, save_raw: bool)[source]#

Handle aggregation and saving of results

varunayan.core.calculate_map_dimensions(west: float, east: float, south: float, north: float) Tuple[int, int][source]#

Calculate proportional width/height for ASCII map

varunayan.core.cleanup_temp_files(request_id: str, temp_geojson_file: str)[source]#

Clean up temporary files

varunayan.core.download_with_retry(download_func: Callable[[...], str | None], params: ProcessingParams, chunk_id: str | None = None) str | None[source]#

Generic download function with retry logic

varunayan.core.draw_geojson_ascii(geojson_data: Dict[str, Any])[source]#

Draws a mini ASCII map showing the GeoJSON polygons. :param geojson_data: Loaded GeoJSON data (must be FeatureCollection)

varunayan.core.era5ify_bbox(request_id: str, variables: List[str], start_date: str, end_date: str, north: float, south: float, east: float, west: float, dataset_type: str = 'single', pressure_levels: List[str] | None = None, frequency: str = 'hourly', resolution: float = 0.25, verbosity: int = 0, save_raw: bool = True) DataFrame[source]#

Public function for processing with bounding box

varunayan.core.era5ify_geojson(request_id: str, variables: List[str], start_date: str, end_date: str, json_file: str, dataset_type: str = 'single', pressure_levels: List[str] | None = None, frequency: str = 'hourly', resolution: float = 0.25, verbosity: int = 0, save_raw: bool = True) DataFrame[source]#

Public function for processing with GeoJSON

varunayan.core.era5ify_point(request_id: str, variables: List[str], start_date: str, end_date: str, latitude: float, longitude: float, dataset_type: str = 'single', pressure_levels: List[str] | None = None, frequency: str = 'hourly', verbosity: int = 0, save_raw: bool = True) DataFrame[source]#
varunayan.core.load_and_validate_geojson(geojson_file: str) Dict[str, Any][source]#

Load and validate GeoJSON file

varunayan.core.parse_date(date_str: str) datetime[source]#

Parse date string into datetime object

varunayan.core.print_bounding_box(params: ProcessingParams)[source]#

Print bounding box information

Print processing footer information

varunayan.core.print_processing_header(params: ProcessingParams)[source]#

Print processing header information

varunayan.core.print_processing_strategy(params: ProcessingParams)[source]#

Print processing strategy information

varunayan.core.process_era5(params: ProcessingParams, save_raw: bool)[source]#

Main entry point for ERA5 processing

varunayan.core.process_era5_data(params: ProcessingParams, chunk_info: Tuple[int, int] | None = None) DataFrame | None[source]#

Core processing function for both single and pressure level data

varunayan.core.process_time_chunks(params: ProcessingParams, download_func: Callable[[...], str | None], process_func: Callable[[ProcessingParams, int | None, int | None], DataFrame | None]) DataFrame | None[source]#

Handle time-based chunking of downloads and processing

varunayan.core.save_results(params: ProcessingParams, aggregated_df: DataFrame, unique_latlongs: DataFrame, raw_df: DataFrame, save_raw: bool)[source]#

Save all results to files

varunayan.core.set_verbosity(verbosity: int)[source]#
varunayan.core.validate_inputs(params: ProcessingParams)[source]#

Validate all input parameters