smpy.coordinates.base.CoordinateSystem¶
- class smpy.coordinates.base.CoordinateSystem[source]¶
Abstract base class for coordinate systems.
Provides interface for RA/Dec and pixel coordinate systems used in mass mapping. Each coordinate system must implement methods for creating grids, handling boundaries, and transforming coordinates appropriately.
Notes
Subclasses must implement all abstract methods to provide coordinate system specific functionality for gridding shear data and handling coordinate transformations.
- __init__()¶
Methods
__init__()calculate_boundaries(coord1, coord2)Calculate field boundaries and setup coordinate labels.
create_grid(data_df, boundaries, config)Create a shear grid by binning data in the coordinate system.
get_grid_parameters(config)Get grid parameters from config for the specific coordinate system.
prepare_data(data_df)Prepare data for gridding by validating and transforming coordinates.
transform_coordinates(data_df)Transform coordinates if needed (e.g., centering, scaling).
- abstract get_grid_parameters(config)[source]¶
Get grid parameters from config for the specific coordinate system.
Extract coordinate system specific parameters needed for grid creation from the configuration dictionary.
- Parameters:
config (dict) – Configuration dictionary containing coordinate system parameters.
- Returns:
grid_params – Grid parameters dictionary: - For RA/Dec: resolution_arcmin for setting grid spacing - For Pixel: downsample_factor and max_grid_size for binning
- Return type:
dict
- abstract create_grid(data_df, boundaries, config)[source]¶
Create a shear grid by binning data in the coordinate system.
Bin shear measurements onto a regular 2D grid using coordinate system specific binning strategies.
- Parameters:
data_df (pandas.DataFrame) – DataFrame containing coordinates, shear components and weights. Must include coord1_scaled and coord2_scaled from transform_coordinates.
boundaries (dict) – Coordinate boundaries from calculate_boundaries().
config (dict) – Configuration dictionary containing system parameters.
- Returns:
g1_grid (numpy.ndarray) – 2D array containing binned first shear component values.
g2_grid (numpy.ndarray) – 2D array containing binned second shear component values.
- abstract calculate_boundaries(coord1, coord2)[source]¶
Calculate field boundaries and setup coordinate labels.
Determine coordinate ranges and set up appropriate labels and units for the coordinate system.
- Parameters:
coord1 (numpy.ndarray) – First coordinate values (RA or X pixel coordinates).
coord2 (numpy.ndarray) – Second coordinate values (Dec or Y pixel coordinates).
- Returns:
scaled_boundaries (dict) – Dictionary containing scaled coordinate ranges and labels: coord1_min/max, coord2_min/max, coord1_name, coord2_name, units.
true_boundaries (dict) – Dictionary containing true coordinate ranges and labels.
- abstract transform_coordinates(data_df)[source]¶
Transform coordinates if needed (e.g., centering, scaling).
Apply coordinate system specific transformations such as centering or scaling to prepare coordinates for gridding operations.
- Parameters:
data_df (pandas.DataFrame) – DataFrame with original coord1, coord2 coordinate columns.
- Returns:
transformed_df – DataFrame with additional coord1_scaled, coord2_scaled columns containing transformed coordinates ready for gridding.
- Return type:
pandas.DataFrame
- prepare_data(data_df)[source]¶
Prepare data for gridding by validating and transforming coordinates.
Check that required columns exist and ensure coordinates are transformed appropriately before gridding operations.
- Parameters:
data_df (pandas.DataFrame) – Input DataFrame containing coordinates and shear measurements.
- Returns:
processed_df – Processed DataFrame with all required columns and transformed coordinates.
- Return type:
pandas.DataFrame
- Raises:
ValueError – If required columns are missing from the input DataFrame.