Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,9 @@ repository:
# Add GitHub buttons to your book
# See https://jupyterbook.org/customize/config.html#add-a-link-to-your-repository
html:
favicon: favicon.ico # Path to favicon relative to doc/ directory
use_issues_button: true
use_repository_button: true
extra_navbar: ""
extra_footer: ""
home_page_in_navbar: false
119 changes: 8 additions & 111 deletions doc/api_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,125 +13,22 @@ This section provides detailed documentation for all classes, functions, and met
:show-inheritance:

```
### Index Store Module


The main class for creating and managing spatial binning operations.

#### Constructor Parameters

- **ds_high** (*xarray.Dataset*): High-resolution input dataset
- **ds_low** (*xarray.Dataset*): Low-resolution target grid dataset
- **var_name** (*str*): Name of the variable to bin
- **radius** (*float, optional*): Search radius for binning algorithm

#### Key Methods

##### create_binning_index()
Creates a binning index that maps high-resolution points to low-resolution grid cells.

**Returns**: Binning index object for reuse

##### mean_binning()
Performs mean binning operation.

**Parameters**:
- **precomputed_binning_index** (*bool, optional*): Whether to use a precomputed binning index. Defaults to False.

**Returns**: *xarray.Dataset* with binned results

**Usage Example**:
```python
>>> import xarray as xr
>>> from map_binning.binning import Binning
>>> ds_high = xr.open_dataset('high_res_data.nc')
>>> ds_low = xr.open_dataset('low_res_grid.nc')
>>> binning = Binning(ds_high, ds_low, var_name='temperature')
>>> binned_data = binning.mean_binning()
>>> print(binned_data)
```{eval-rst}
.. autoclass:: map_binning.index_store
:members:
:undoc-members:
:show-inheritance:
```

## Utility Functions

### save()
## Utility Functions

```{eval-rst}
.. autofunction:: map_binning.save
```

Save binning indices or results to disk for later use.

**Parameters**:
- **obj**: Object to save (binning index or dataset)
- **filepath** (*str*): Path where to save the file

**Example**:
```python
from map_binning.index_store import save
save(binning_index, 'my_index.pkl')
```

### load()

```{eval-rst}
.. autofunction:: map_binning.load
```

Load previously saved binning indices or results from disk.

**Parameters**:
- **filepath** (*str*): Path to the saved file

**Returns**: Loaded object

**Example**:
```python
from map_binning.index_store import load
index = load('my_index.pkl')
```

## Index Store Module

```{eval-rst}
.. automodule:: map_binning.index_store
:members:
:undoc-members:
:show-inheritance:
```

Module for managing persistent storage of binning indices.

## Constants and Configuration

### Default Parameters

- **DEFAULT_RADIUS**: By default, the search radius for binning is set to 60% of the maximum average spacing between latitude and longitude points in the low-resolution grid. This is calculated as `max(mean_lat_spacing, mean_lon_spacing) * 0.6`.

### Supported Save/Load Format

- **SUPPORTED_FORMATS**: Only pickle files (`.pkl`) generated by the package are supported for save and load operations.

## Error Handling

The package defines custom exceptions for different error conditions:

- **BinningError**: Base exception for binning-related errors
- **InvalidDatasetError**: Raised when input datasets are invalid
- **IndexError**: Raised when binning index operations fail

## Data Types

### Coordinate Systems

The package supports various coordinate systems and projections:

- Geographic coordinates (latitude/longitude)
- Projected coordinate systems
- Custom grid definitions

### Supported Data Formats

Input datasets can be in various formats supported by xarray:
- NetCDF (.nc, .nc4)
- Zarr
- GRIB
- HDF5
```
Loading