canvod.auxiliary API Reference¶
SP3 ephemeris and CLK clock correction processing, interpolation, coordinate transformations, and the GNSS product registry.
Package¶
canvod-aux: Auxiliary data augmentation for GNSS VOD analysis
Handles downloading, parsing, and interpolating SP3 ephemerides and clock corrections for GNSS satellite data processing.
Sp3File
¶
Bases: AuxFile
Handler for SP3 orbit files with multi-product support.
Now supports all IGS analysis centers via product registry: COD, GFZ, ESA, JPL, IGS, WHU, GRG, SHA
Notes¶
This is a Pydantic dataclass with arbitrary_types_allowed=True.
Attributes¶
date : str String in YYYYDOY format. agency : str Agency code (e.g., "COD", "GFZ", "ESA"). product_type : str Product type ("final", "rapid"). ftp_server : str Base URL for downloads. local_dir : Path Local storage directory. add_velocities : bool | None, default True Whether to compute velocities. dimensionless : bool | None, default True Whether to strip units (store magnitudes only). product_spec : ProductSpec | None, optional Product specification resolved from the registry.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/reader.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 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 | |
__post_init__()
¶
Initialize with product validation.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/reader.py
62 63 64 65 66 67 68 69 70 71 | |
get_interpolation_strategy()
¶
Get appropriate interpolation strategy for SP3 files.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/reader.py
73 74 75 76 77 78 79 | |
generate_filename_based_on_type()
¶
Generate filename using product registry.
Pattern: {PREFIX}{YYYYDOY}0000_ORB.SP3}_{SAMPLING
Example: COD0MGXFIN_20240150000_01D_05M_ORB.SP3
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/reader.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
download_aux_file()
¶
Download SP3 file, trying all servers from the product registry.
Servers are tried in priority order from products.toml. Auth-required servers are skipped when no credentials are configured. Warnings are printed when falling back to alternate servers.
Raises¶
RuntimeError If download fails from all available servers. ValueError If GPS week calculation fails.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/reader.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
read_file()
¶
Read and validate SP3 file.
Returns¶
xr.Dataset Dataset with satellite positions (X, Y, Z) in meters.
Raises¶
FileNotFoundError If file does not exist. ValueError If validation fails.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/reader.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
compute_velocity(ds)
¶
Compute satellite velocities from position data.
Uses central differences for interior points, forward/backward differences for endpoints.
Parameters¶
ds : xr.Dataset Dataset with X, Y, Z coordinates.
Returns¶
xr.Dataset Dataset augmented with Vx, Vy, Vz velocities.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/reader.py
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 | |
ClkFile
¶
Bases: AuxFile
Handler for GNSS clock files in CLK format.
This class reads and processes clock offset files containing satellite clock corrections. It handles the parsing of CLK format files and provides the data in xarray Dataset format.
Supports multiple analysis centers via product registry with proper FTP paths and filename conventions.
Notes¶
This is a Pydantic dataclass with arbitrary_types_allowed=True.
Attributes¶
date : str String in YYYYDOY format representing the start date. agency : str Analysis center identifier (e.g., "COD", "GFZ"). product_type : str Product type ("final", "rapid", "ultrarapid"). ftp_server : str Base URL for file downloads. local_dir : Path Local storage directory. dimensionless : bool | None, default True If True, outputs magnitude-only values (no units attached).
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/clock/reader.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 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 | |
__post_init__()
¶
Initialize CLK file handler.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/clock/reader.py
65 66 67 68 69 70 | |
get_interpolation_strategy()
¶
Get appropriate interpolation strategy for CLK files.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/clock/reader.py
72 73 74 75 76 77 78 | |
generate_filename_based_on_type()
¶
Generate standard CLK filename using product registry.
Uses product registry to get correct prefix for the agency/product combination. Filename format: {PREFIX}_{YYYYDOY}0000_01D_30S_CLK.CLK
Returns¶
Path Filename according to CLK conventions.
Raises¶
ValueError If agency/product combination not in registry.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/clock/reader.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
download_aux_file()
¶
Download CLK file, trying all servers from the product registry.
Servers are tried in priority order from products.toml. Auth-required servers are skipped when no credentials are configured. Warnings are printed when falling back to alternate servers.
Raises¶
RuntimeError If file cannot be downloaded from any available server. ValueError If GPS week calculation fails.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/clock/reader.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
read_file()
¶
Read and parse CLK file into xarray Dataset.
Uses modular parser for data extraction and validator for quality checks. Applies unit conversion from microseconds to seconds.
Returns¶
xr.Dataset Clock offsets with dimensions (epoch, sv). Values are in seconds (or dimensionless if specified).
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/clock/reader.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
AuxFile
¶
Bases: ABC
Abstract base class for GNSS auxiliary files (SP3, CLK, IONEX, etc.).
This class provides two ways to create instances: 1. from_datetime_date(): Create from a datetime.date object and metadata 2. from_file(): Create directly from an existing file path
The class handles both newly downloaded files and existing local files, maintaining consistent behavior regardless of how the instance is created.
FTP Server Configuration:¶
- user_email: Optional email for NASA CDDIS authentication
- If None: Uses ESA FTP server exclusively (no authentication required)
- If provided: Enables NASA CDDIS as fallback server (requires registration)
- To enable CDDIS, set nasa_earthdata_acc_mail in config/processing.yaml
Notes¶
This is a Pydantic dataclass with arbitrary_types_allowed=True, and
it uses ABC to define required subclass hooks.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/core/base.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 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 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | |
data
property
¶
Access the file's data, loading it if necessary.
__post_init__()
¶
Initialize after dataclass creation.
Sets up paths, downloader, and verifies local file existence.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/core/base.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
from_datetime_date(date, agency, product_type, ftp_server, local_dir, **kwargs)
classmethod
¶
Create an AuxFile instance from a datetime.date.
Parameters¶
date : datetime.date Date for the desired auxiliary file. agency : str Agency providing the data (e.g., "COD", "IGS"). product_type : str Product type ("final", "rapid", "ultrarapid"). ftp_server : str Base URL for file downloads. local_dir : Path Directory for storing files locally. **kwargs : Any Extra keyword arguments for subclass construction.
Returns¶
AuxFile A new instance of the AuxFile subclass.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/core/base.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
from_file(fpath, **kwargs)
classmethod
¶
Create an AuxFile instance from an existing file path.
Parameters¶
fpath : Path Path to the existing GNSS file. **kwargs : Any Extra keyword arguments for subclass construction.
Returns¶
AuxFile A new instance of the AuxFile subclass.
Raises¶
FileNotFoundError If the specified file does not exist.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/core/base.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
download_file(url, destination, file_info=None)
¶
Download a file using the configured downloader.
Parameters¶
url : str Download URL. destination : Path Local file destination. file_info : dict, optional Extra info passed to the downloader.
Returns¶
Path Path to the downloaded file.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/core/base.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
download_with_fallback(ftp_path, destination, file_info=None, product_spec=None)
¶
Download a file, trying all servers from the product spec in priority order.
Iterates through the product's FTP server list (from products.toml), skipping servers that require authentication when no credentials are configured. Warns when falling back to an alternate server. Raises a clear error when all servers fail.
Parameters¶
ftp_path : str
Server-relative path (e.g. /gnss/products/2345/FILE.gz).
destination : Path
Local file destination.
file_info : dict, optional
Extra context passed to the downloader.
product_spec : ProductSpec, optional
Product specification with ftp_servers list. If None, falls
back to single-server download using self.ftp_server.
Returns¶
Path Path to the downloaded file.
Raises¶
RuntimeError If download fails from all available servers.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/core/base.py
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 | |
read_file()
abstractmethod
¶
Read and parse the auxiliary file.
Returns¶
xr.Dataset Parsed dataset representation of the file.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/core/base.py
292 293 294 295 296 297 298 299 300 301 | |
get_interpolation_strategy()
abstractmethod
¶
Get the interpolation strategy for this file type.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/core/base.py
303 304 305 306 | |
check_file_exists()
¶
Verify file exists locally or download it if needed.
Returns¶
Path Local file path.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/core/base.py
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | |
generate_filename_based_on_type()
abstractmethod
¶
Generate the appropriate filename for this type of auxiliary file.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/core/base.py
334 335 336 337 | |
download_aux_file()
abstractmethod
¶
Download the auxiliary file from the specified FTP server.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/core/base.py
339 340 341 342 | |
Interpolator
¶
Bases: ABC
Abstract base class for interpolation strategies.
Notes¶
This is a Pydantic dataclass with arbitrary_types_allowed=True and
uses ABC to define required interpolation hooks.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/interpolation/interpolator.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
interpolate(ds, target_epochs)
abstractmethod
¶
Interpolate dataset to match target epochs.
Parameters¶
ds : xr.Dataset Source dataset with (epoch, sid) dimensions. target_epochs : np.ndarray Target epoch grid (datetime64).
Returns¶
xr.Dataset Interpolated dataset at target epochs.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/interpolation/interpolator.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
to_attrs()
¶
Convert interpolator to attrs-compatible dictionary.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/interpolation/interpolator.py
91 92 93 94 95 96 | |
InterpolatorConfig
¶
Base class for interpolator configuration.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/interpolation/interpolator.py
21 22 23 24 25 26 | |
to_dict()
¶
Convert config to dictionary for attrs storage.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/interpolation/interpolator.py
24 25 26 | |
DatasetMatcher
¶
Match auxiliary datasets to a reference RINEX dataset temporally.
Handles temporal alignment of datasets with different sampling rates using appropriate interpolation strategies. The reference dataset (typically RINEX observations) remains unchanged while auxiliary datasets are interpolated to match its epochs.
The matcher: 1. Validates all datasets have required dimensions (epoch, sid) 2. Determines relative temporal resolutions 3. Applies appropriate interpolation: - Higher resolution aux → nearest neighbor - Lower resolution aux → specialized interpolator from metadata
Examples¶
from canvod.auxiliary.matching import DatasetMatcher
matcher = DatasetMatcher() matched = matcher.match_datasets( ... rinex_ds, ... ephemerides=sp3_data, ... clock=clk_data ... )
Auxiliary datasets now aligned to RINEX epochs¶
len(matched['ephemerides'].epoch) == len(rinex_ds.epoch) True len(matched['clock'].epoch) == len(rinex_ds.epoch) True
Notes¶
- Reference dataset should be the RINEX observations
- Auxiliary datasets should have 'interpolator_config' in attrs
- If no interpolator config, falls back to nearest neighbor
- Temporal distance is tracked for quality assessment
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/matching/dataset_matcher.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 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 | |
match_datasets(reference_ds, **aux_datasets)
¶
Match auxiliary datasets to reference dataset epochs.
Parameters¶
reference_ds : xr.Dataset Primary dataset (usually RINEX observations) that defines the target epoch timeline. This dataset remains unchanged. **aux_datasets : dict[str, xr.Dataset] Named auxiliary datasets to align to reference epochs. Keys become the names in the returned dict. Example: ephemerides=sp3_data, clock=clk_data
Returns¶
dict[str, xr.Dataset] Dictionary of matched auxiliary datasets, all aligned to reference_ds.epoch. Keys match the input **aux_datasets keys.
Raises¶
ValueError - If no auxiliary datasets provided - If datasets missing required dimensions - If interpolation config missing (warns, doesn't raise)
Examples¶
matcher = DatasetMatcher() matched = matcher.match_datasets( ... rinex_ds, ... ephemerides=sp3_data, ... clock=clk_data ... ) matched.keys() dict_keys(['ephemerides', 'clock'])
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/matching/dataset_matcher.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
ECEFPosition
dataclass
¶
Earth-Centered, Earth-Fixed (ECEF) position in meters.
ECEF is a Cartesian coordinate system with: - Origin at Earth's center of mass - X-axis pointing to 0° latitude, 0° longitude (Prime Meridian at Equator) - Y-axis pointing to 0° latitude, 90° East longitude - Z-axis pointing to North Pole
Parameters¶
x : float X coordinate in meters. y : float Y coordinate in meters. z : float Z coordinate in meters.
Examples¶
From RINEX dataset metadata¶
pos = ECEFPosition.from_ds_metadata(rinex_ds) print(f"X: {pos.x:.3f} m")
Manual creation¶
pos = ECEFPosition(x=4194304.123, y=176481.234, z=4780013.456) lat, lon, alt = pos.to_geodetic()
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/position/position.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
to_geodetic()
¶
Convert ECEF to geodetic coordinates.
Returns¶
tuple[float, float, float] (latitude, longitude, altitude) where: - latitude: degrees [-90, 90] - longitude: degrees [-180, 180] - altitude: meters above WGS84 ellipsoid
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/position/position.py
49 50 51 52 53 54 55 56 57 58 59 60 61 | |
from_ds_metadata(ds)
classmethod
¶
Extract ECEF position from RINEX dataset metadata.
Reads from standard RINEX header attributes.
Parameters¶
ds : xr.Dataset RINEX dataset with position in attributes.
Returns¶
ECEFPosition Receiver position in ECEF.
Raises¶
KeyError If position attributes not found in dataset.
Examples¶
from canvod.readers import Rnxv3Obs rnx = Rnxv3Obs(fpath="station.24o") ds = rnx.to_ds() pos = ECEFPosition.from_ds_metadata(ds)
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/position/position.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
GeodeticPosition
dataclass
¶
Geodetic (WGS84) position.
Parameters¶
lat : float Latitude in degrees [-90, 90]. lon : float Longitude in degrees [-180, 180]. alt : float Altitude in meters above WGS84 ellipsoid.
Examples¶
pos = GeodeticPosition(lat=48.208, lon=16.373, alt=200.0) print(f"Vienna: {pos.lat}°N, {pos.lon}°E, {pos.alt}m")
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/position/position.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
to_ecef()
¶
Convert geodetic to ECEF coordinates.
Returns¶
ECEFPosition Position in ECEF frame.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/position/position.py
143 144 145 146 147 148 149 150 151 152 | |
Preprocessing¶
Preprocessing utilities for auxiliary GNSS data.
Handles conversion of raw auxiliary data (SP3, CLK) from satellite vehicle (sv) dimension to signal ID (sid) dimension required for matching with RINEX data.
Matches gnssvodpy.icechunk_manager.preprocessing.IcechunkPreprocessor exactly.
flush_sid_accumulators()
¶
Return accumulated SID issues and clear the module-level accumulators.
Called once per RINEX file at the end of preprocess_with_hermite_aux.
The returned dict is aggregated by the main process across all files for
a receiver and logged once per receiver run.
Returns¶
dict[str, list[str]]
Keys: "not_in_global_space", "dropped_by_filter".
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/preprocessing.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
create_sv_to_sid_mapping(svs, aggregate_glonass_fdma=True)
¶
Build mapping from each SV to its possible SIDs.
Builds all SIDs from known band/code combinations.
Parameters¶
svs : list[str] List of space vehicles (e.g., ["G01", "E02"]). aggregate_glonass_fdma : bool, default True Whether to aggregate GLONASS FDMA bands.
Returns¶
dict[str, list[str]] Mapping from sv → list of SIDs.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/preprocessing.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
map_aux_sv_to_sid(aux_ds, fill_value=np.nan, aggregate_glonass_fdma=True)
¶
Transform auxiliary dataset from sv → sid dimension.
Each sv in the dataset is expanded to all its possible SIDs. Values are replicated across SIDs for the same satellite.
Parameters¶
aux_ds : xr.Dataset Dataset with 'sv' dimension. fill_value : float, default np.nan Fill value for missing entries. aggregate_glonass_fdma : bool, default True Whether to aggregate GLONASS FDMA bands.
Returns¶
xr.Dataset Dataset with 'sid' dimension replacing 'sv'.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/preprocessing.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
pad_to_global_sid(ds, keep_sids=None, aggregate_glonass_fdma=True)
¶
Pad dataset so it has all possible SIDs across all constellations. Ensures consistent sid dimension for appending to Icechunk.
Parameters¶
ds : xr.Dataset Dataset with 'sid' dimension. keep_sids : list[str] | None Optional list of specific SIDs to keep. If None, keeps all. aggregate_glonass_fdma : bool, default True Whether to aggregate GLONASS FDMA bands.
Returns¶
xr.Dataset Dataset padded with NaN for missing SIDs.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/preprocessing.py
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 | |
normalize_sid_dtype(ds)
¶
normalize_sid_dtype(ds: xr.Dataset) -> xr.Dataset
normalize_sid_dtype(ds: None) -> None
Ensure sid coordinate uses object dtype.
Parameters¶
ds : xr.Dataset Dataset with 'sid' coordinate.
Returns¶
xr.Dataset Dataset with sid as object dtype.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/preprocessing.py
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | |
strip_fillvalue(ds)
¶
strip_fillvalue(ds: xr.Dataset) -> xr.Dataset
strip_fillvalue(ds: None) -> None
Remove _FillValue attrs/encodings.
Parameters¶
ds : xr.Dataset Dataset to clean.
Returns¶
xr.Dataset Dataset with _FillValue attributes removed.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/preprocessing.py
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | |
add_future_datavars(ds, var_config)
¶
Add placeholder data variables from a configuration dictionary.
Parameters¶
ds : xr.Dataset Dataset to add variables to. var_config : dict[str, dict[str, Any]] Configuration dict with structure: { "var_name": { "fill_value": value, "dtype": numpy dtype, "attrs": {attribute dict} } }
Returns¶
xr.Dataset Dataset with new variables added.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/preprocessing.py
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | |
prep_aux_ds(aux_ds, fill_value=np.nan, aggregate_glonass_fdma=True, keep_sids=None)
¶
Preprocess auxiliary dataset before writing to Icechunk.
Performs complete 4-step preprocessing: 1. Convert sv → sid dimension 2. Pad to global sid list (all constellations) or filter to keep_sids 3. Normalize sid dtype to object 4. Strip _FillValue attributes
This matches gnssvodpy.icechunk_manager.preprocessing.IcechunkPreprocessor.prep_aux_ds().
Parameters¶
aux_ds : xr.Dataset Dataset with 'sv' dimension. fill_value : float, default np.nan Fill value for missing entries. aggregate_glonass_fdma : bool, default True Whether to aggregate GLONASS FDMA bands. keep_sids : list[str] | None, default None List of specific SIDs to keep. If None, keeps all possible SIDs.
Returns¶
xr.Dataset Fully preprocessed dataset ready for Icechunk or interpolation.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/preprocessing.py
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 | |
preprocess_aux_for_interpolation(aux_ds, fill_value=np.nan, full_preprocessing=False, aggregate_glonass_fdma=True)
¶
Preprocess auxiliary dataset before interpolation.
Converts satellite vehicle (sv) dimension to Signal ID (sid) dimension, which is required for matching with RINEX observations after interpolation.
Parameters¶
aux_ds : xr.Dataset Raw auxiliary dataset with 'sv' dimension. fill_value : float, default np.nan Fill value for missing entries. full_preprocessing : bool, default False If True, applies full 4-step preprocessing (pad_to_global_sid, normalize_sid_dtype, strip_fillvalue). If False, only converts sv → sid (sufficient for interpolation). aggregate_glonass_fdma : bool, default True Whether to aggregate GLONASS FDMA bands.
Returns¶
xr.Dataset Preprocessed dataset with 'sid' dimension.
Notes¶
This must be called BEFORE interpolation. The workflow is: 1. Load raw SP3/CLK data (sv dimension) 2. Convert sv → sid (this function) 3. Interpolate to target epochs 4. Match with RINEX data (sid dimension)
For most interpolation use cases, full_preprocessing=False is sufficient.
Use full_preprocessing=True when preparing data for Icechunk storage.
Examples¶
Load raw SP3 data¶
sp3_data = Sp3File(...).to_dataset() sp3_data.dims
Preprocess before interpolation (minimal)¶
sp3_preprocessed = preprocess_aux_for_interpolation(sp3_data) sp3_preprocessed.dims
Preprocess before Icechunk (full)¶
sp3_preprocessed = preprocess_aux_for_interpolation( ... sp3_data, ... full_preprocessing=True, ... ) sp3_preprocessed.dims {'epoch': 96, 'sid': ~2000} # Padded to all possible sids
Now interpolate¶
sp3_interp = interpolator.interpolate(sp3_preprocessed, target_epochs)
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/preprocessing.py
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 | |
Interpolation¶
Interpolation strategies for GNSS auxiliary data.
ClockConfig
¶
Bases: InterpolatorConfig
Configuration for clock correction interpolation.
Attributes¶
window_size : int, default 9 Window size for discontinuity detection. jump_threshold : float, default 1e-6 Threshold for detecting clock jumps (seconds).
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/interpolation/interpolator.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
ClockInterpolationStrategy
¶
Bases: Interpolator
Piecewise linear interpolation for clock corrections.
Detects and handles discontinuities (clock jumps) properly.
Examples¶
from canvod.auxiliary.interpolation import ( ... ClockInterpolationStrategy, ClockConfig, ... )
config = ClockConfig(window_size=9, jump_threshold=1e-6) interpolator = ClockInterpolationStrategy(config=config)
Interpolate to RINEX epochs¶
clk_interp = interpolator.interpolate(clk_data, rinex_epochs)
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/interpolation/interpolator.py
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 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | |
interpolate(ds, target_epochs)
¶
Interpolate clock corrections with discontinuity handling.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/interpolation/interpolator.py
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 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | |
Interpolator
¶
Bases: ABC
Abstract base class for interpolation strategies.
Notes¶
This is a Pydantic dataclass with arbitrary_types_allowed=True and
uses ABC to define required interpolation hooks.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/interpolation/interpolator.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
interpolate(ds, target_epochs)
abstractmethod
¶
Interpolate dataset to match target epochs.
Parameters¶
ds : xr.Dataset Source dataset with (epoch, sid) dimensions. target_epochs : np.ndarray Target epoch grid (datetime64).
Returns¶
xr.Dataset Interpolated dataset at target epochs.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/interpolation/interpolator.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
to_attrs()
¶
Convert interpolator to attrs-compatible dictionary.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/interpolation/interpolator.py
91 92 93 94 95 96 | |
InterpolatorConfig
¶
Base class for interpolator configuration.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/interpolation/interpolator.py
21 22 23 24 25 26 | |
to_dict()
¶
Convert config to dictionary for attrs storage.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/interpolation/interpolator.py
24 25 26 | |
Sp3Config
¶
Bases: InterpolatorConfig
Configuration for SP3 ephemeris interpolation.
Attributes¶
use_velocities : bool, default True Use Hermite splines with satellite velocities if available. fallback_method : str, default 'linear' Interpolation method when velocities are unavailable.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/interpolation/interpolator.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
Sp3InterpolationStrategy
¶
Bases: Interpolator
Hermite cubic spline interpolation for SP3 ephemeris data.
Uses satellite velocities (Vx, Vy, Vz) for higher accuracy. Falls back to linear interpolation if velocities unavailable.
Examples¶
from canvod.auxiliary.interpolation import Sp3InterpolationStrategy, Sp3Config
config = Sp3Config(use_velocities=True, fallback_method='linear') interpolator = Sp3InterpolationStrategy(config=config)
Interpolate to RINEX epochs¶
sp3_interp = interpolator.interpolate(sp3_data, rinex_epochs)
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/interpolation/interpolator.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 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 | |
interpolate(ds, target_epochs)
¶
Interpolate SP3 ephemeris to target epochs.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/interpolation/interpolator.py
119 120 121 122 123 | |
create_interpolator_from_attrs(attrs)
¶
Recreate interpolator instance from dataset attributes.
Parameters¶
attrs : dict Dataset attributes containing interpolator_config.
Returns¶
Interpolator Reconstructed interpolator instance.
Examples¶
Save interpolator config in dataset¶
ds.attrs['interpolator_config'] = interpolator.to_attrs()
Later, recreate interpolator¶
interpolator = create_interpolator_from_attrs(ds.attrs)
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/interpolation/interpolator.py
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 | |
Ephemeris (SP3)¶
Ephemeris (satellite orbit) data handling.
This module provides tools for reading, parsing, and validating satellite ephemeris data from SP3 format files, as well as the EphemerisProvider ABC for augmenting GNSS datasets with angular coordinates.
Sp3Parser
¶
Parser for SP3 (Standard Product #3) orbit files.
Handles parsing of SP3 format files containing precise satellite orbit data. Implements optimized single-pass reading for performance.
Parameters¶
fpath : Path Path to SP3 file. dimensionless : bool, default True If True, strip units from output.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/parser.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 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 | |
__init__(fpath, dimensionless=True)
¶
Initialize SP3 parser.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/parser.py
26 27 28 29 | |
parse()
¶
Parse SP3 file to xarray Dataset.
Returns¶
xr.Dataset Dataset with satellite positions (X, Y, Z) in meters.
Raises¶
FileNotFoundError If file does not exist. ValueError If file format is invalid.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/parser.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
AgencyEphemerisProvider
¶
Bases: EphemerisProvider
SP3/CLK-based ephemeris from analysis centres.
Downloads final/rapid/ultra products from COD, ESA, IGS etc., interpolates via Hermite cubic splines, and computes theta/phi via ECEF→spherical coordinate transformation.
Parameters¶
agency : str
Analysis centre code ("COD", "ESA", "GFZ", "JPL").
product_type : str
Product type ("final", "rapid", "ultra").
aux_data_dir : Path, optional
Directory for cached aux Zarr files.
keep_sids : list[str], optional
SID filter list.
store_radial_distance : bool
Whether to keep r in the output.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/provider.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 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 | |
preprocess_day(date, site_config)
¶
Download SP3/CLK and interpolate to observation epochs.
Creates a Zarr store with interpolated satellite positions (X, Y, Z) and clock corrections at the observation sampling rate.
Parameters¶
date : str
Date in YYYYDOY format.
site_config : Any
Site configuration (needs gnss_site_data_root, receiver info).
Returns¶
Path Path to the preprocessed aux Zarr store.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/provider.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 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 | |
augment_dataset(ds, receiver_position)
¶
Add theta/phi to dataset using preprocessed SP3/CLK data.
Parameters¶
ds : xr.Dataset GNSS observation dataset. receiver_position : ECEFPosition Receiver ECEF position.
Returns¶
xr.Dataset Augmented dataset with theta, phi (and optionally r).
Raises¶
RuntimeError
If preprocess_day() has not been called.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/provider.py
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 | |
EphemerisProvider
¶
Bases: ABC
Abstract base class for satellite ephemeris providers.
Implementations augment a GNSS dataset with angular coordinates (theta, phi) relative to a receiver position.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/provider.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
augment_dataset(ds, receiver_position)
abstractmethod
¶
Add theta and phi (and optionally r) to ds.
Parameters¶
ds : xr.Dataset
GNSS observation dataset with (epoch, sid) dims.
receiver_position : ECEFPosition
Receiver ECEF coordinates.
Returns¶
xr.Dataset
Dataset with theta, phi (and optionally r) added.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/provider.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
preprocess_day(date, site_config)
abstractmethod
¶
Download / prepare ephemeris data for one day.
Parameters¶
date : str
Date in YYYYDOY format.
site_config : Any
Site configuration object providing receiver info, data root, etc.
Returns¶
Path or None
Path to cached/preprocessed ephemeris data, or None
if preparation is not needed (e.g. broadcast provider).
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/provider.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
SbfBroadcastProvider
¶
Bases: EphemerisProvider
Ephemeris from SBF SatVisibility broadcast data.
Transfers theta/phi directly from SBF metadata datasets, skipping external orbit/clock downloads entirely. Only works when the source format is SBF.
Parameters¶
canopy_file : Path, optional Path to canopy SBF file for reference receivers in shared-position mode. When provided, the canopy file's geometry overrides the reference file's own geometry. canopy_reader_format : str Reader format for the canopy file.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/provider.py
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 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | |
preprocess_day(date, site_config)
¶
No preprocessing needed for broadcast ephemeris.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/provider.py
317 318 319 320 321 322 323 | |
augment_dataset(ds, receiver_position, *, aux_datasets=None)
¶
Add theta/phi from SBF SatVisibility metadata.
Parameters¶
ds : xr.Dataset
SBF observation dataset.
receiver_position : ECEFPosition
Receiver ECEF position (unused but required by ABC).
aux_datasets : dict, optional
Auxiliary datasets from reader.to_ds_and_auxiliary().
Must contain "sbf_obs" with theta/phi.
Returns¶
xr.Dataset Dataset with theta/phi added from SBF broadcast.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/provider.py
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | |
Sp3File
¶
Bases: AuxFile
Handler for SP3 orbit files with multi-product support.
Now supports all IGS analysis centers via product registry: COD, GFZ, ESA, JPL, IGS, WHU, GRG, SHA
Notes¶
This is a Pydantic dataclass with arbitrary_types_allowed=True.
Attributes¶
date : str String in YYYYDOY format. agency : str Agency code (e.g., "COD", "GFZ", "ESA"). product_type : str Product type ("final", "rapid"). ftp_server : str Base URL for downloads. local_dir : Path Local storage directory. add_velocities : bool | None, default True Whether to compute velocities. dimensionless : bool | None, default True Whether to strip units (store magnitudes only). product_spec : ProductSpec | None, optional Product specification resolved from the registry.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/reader.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 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 | |
__post_init__()
¶
Initialize with product validation.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/reader.py
62 63 64 65 66 67 68 69 70 71 | |
get_interpolation_strategy()
¶
Get appropriate interpolation strategy for SP3 files.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/reader.py
73 74 75 76 77 78 79 | |
generate_filename_based_on_type()
¶
Generate filename using product registry.
Pattern: {PREFIX}{YYYYDOY}0000_ORB.SP3}_{SAMPLING
Example: COD0MGXFIN_20240150000_01D_05M_ORB.SP3
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/reader.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
download_aux_file()
¶
Download SP3 file, trying all servers from the product registry.
Servers are tried in priority order from products.toml. Auth-required servers are skipped when no credentials are configured. Warnings are printed when falling back to alternate servers.
Raises¶
RuntimeError If download fails from all available servers. ValueError If GPS week calculation fails.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/reader.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
read_file()
¶
Read and validate SP3 file.
Returns¶
xr.Dataset Dataset with satellite positions (X, Y, Z) in meters.
Raises¶
FileNotFoundError If file does not exist. ValueError If validation fails.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/reader.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
compute_velocity(ds)
¶
Compute satellite velocities from position data.
Uses central differences for interior points, forward/backward differences for endpoints.
Parameters¶
ds : xr.Dataset Dataset with X, Y, Z coordinates.
Returns¶
xr.Dataset Dataset augmented with Vx, Vy, Vz velocities.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/reader.py
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 | |
Sp3Validator
¶
Validator for SP3 orbit files.
Performs format and data quality checks on parsed SP3 datasets.
Parameters¶
dataset : xr.Dataset Parsed SP3 dataset. fpath : Path Path to the original file.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/validator.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
__init__(dataset, fpath)
¶
Initialize validator.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/validator.py
23 24 25 26 27 28 29 30 31 32 33 | |
validate()
¶
Run all validation checks.
Returns¶
FileValidationResult Validation result with errors and warnings.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/validator.py
35 36 37 38 39 40 41 42 43 44 45 46 47 | |
get_summary()
¶
Get validation summary.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/ephemeris/validator.py
86 87 88 | |
Clock (CLK)¶
Clock correction data handling.
This module provides tools for reading, parsing, and validating satellite clock correction data from RINEX CLK format files.
ClkFile
¶
Bases: AuxFile
Handler for GNSS clock files in CLK format.
This class reads and processes clock offset files containing satellite clock corrections. It handles the parsing of CLK format files and provides the data in xarray Dataset format.
Supports multiple analysis centers via product registry with proper FTP paths and filename conventions.
Notes¶
This is a Pydantic dataclass with arbitrary_types_allowed=True.
Attributes¶
date : str String in YYYYDOY format representing the start date. agency : str Analysis center identifier (e.g., "COD", "GFZ"). product_type : str Product type ("final", "rapid", "ultrarapid"). ftp_server : str Base URL for file downloads. local_dir : Path Local storage directory. dimensionless : bool | None, default True If True, outputs magnitude-only values (no units attached).
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/clock/reader.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 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 | |
__post_init__()
¶
Initialize CLK file handler.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/clock/reader.py
65 66 67 68 69 70 | |
get_interpolation_strategy()
¶
Get appropriate interpolation strategy for CLK files.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/clock/reader.py
72 73 74 75 76 77 78 | |
generate_filename_based_on_type()
¶
Generate standard CLK filename using product registry.
Uses product registry to get correct prefix for the agency/product combination. Filename format: {PREFIX}_{YYYYDOY}0000_01D_30S_CLK.CLK
Returns¶
Path Filename according to CLK conventions.
Raises¶
ValueError If agency/product combination not in registry.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/clock/reader.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
download_aux_file()
¶
Download CLK file, trying all servers from the product registry.
Servers are tried in priority order from products.toml. Auth-required servers are skipped when no credentials are configured. Warnings are printed when falling back to alternate servers.
Raises¶
RuntimeError If file cannot be downloaded from any available server. ValueError If GPS week calculation fails.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/clock/reader.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
read_file()
¶
Read and parse CLK file into xarray Dataset.
Uses modular parser for data extraction and validator for quality checks. Applies unit conversion from microseconds to seconds.
Returns¶
xr.Dataset Clock offsets with dimensions (epoch, sv). Values are in seconds (or dimensionless if specified).
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/clock/reader.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
parse_clk_data(file_handle)
¶
Parse CLK data records using two-pass strategy.
Two-Pass Strategy
Pass 1: Collect all unique epochs and satellites Pass 2: Fill data arrays with clock offsets
This ensures we capture all satellites, even if they're not in the header, and handles satellites appearing/disappearing during the time period.
Parameters¶
file_handle : TextIO Open file object positioned after header.
Returns¶
tuple[list[datetime.datetime], list[str], np.ndarray] (epochs, satellites, clock_offsets) where: - epochs: list of datetime objects - satellites: sorted list of satellite codes - clock_offsets: 2D array (epochs × satellites) in microseconds
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/clock/parser.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
parse_clk_file(filepath)
¶
Parse complete CLK file.
Parameters¶
filepath : Path Path to CLK file.
Returns¶
tuple[list[datetime.datetime], list[str], np.ndarray] (epochs, satellites, clock_offsets).
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/clock/parser.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
parse_clk_header(file_handle)
¶
Parse CLK file header to extract satellite list.
Parameters¶
file_handle : TextIO Open file object positioned at start.
Returns¶
set[str] Satellite identifiers (e.g., "G01", "R01").
Raises¶
ValueError If header format is invalid.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/clock/parser.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
check_clk_data_quality(ds, min_coverage=80.0)
¶
Check if CLK data meets minimum quality requirements.
Parameters¶
ds : xr.Dataset Dataset from a CLK file. min_coverage : float, default 80.0 Minimum required data coverage percentage.
Returns¶
bool True if data quality is acceptable.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/clock/validator.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
validate_clk_dataset(ds)
¶
Validate CLK dataset structure and data quality.
Checks
- Required variable exists (clock_offset)
- Required coordinates exist (epoch, sv)
- Data completeness (percentage of valid values)
- Temporal consistency (monotonic epochs)
Parameters¶
ds : xr.Dataset Dataset from a CLK file.
Returns¶
dict[str, bool | float | int] Validation results with keys: - has_clock_offset - has_epoch - has_sv - valid_data_percent - epochs_monotonic - num_epochs - num_satellites
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/clock/validator.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
Position and Coordinates¶
Position and coordinate transformations for GNSS data.
Provides ECEF/geodetic position representations and spherical coordinate computation for satellite-receiver geometry analysis.
ECEFPosition
dataclass
¶
Earth-Centered, Earth-Fixed (ECEF) position in meters.
ECEF is a Cartesian coordinate system with: - Origin at Earth's center of mass - X-axis pointing to 0° latitude, 0° longitude (Prime Meridian at Equator) - Y-axis pointing to 0° latitude, 90° East longitude - Z-axis pointing to North Pole
Parameters¶
x : float X coordinate in meters. y : float Y coordinate in meters. z : float Z coordinate in meters.
Examples¶
From RINEX dataset metadata¶
pos = ECEFPosition.from_ds_metadata(rinex_ds) print(f"X: {pos.x:.3f} m")
Manual creation¶
pos = ECEFPosition(x=4194304.123, y=176481.234, z=4780013.456) lat, lon, alt = pos.to_geodetic()
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/position/position.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | |
to_geodetic()
¶
Convert ECEF to geodetic coordinates.
Returns¶
tuple[float, float, float] (latitude, longitude, altitude) where: - latitude: degrees [-90, 90] - longitude: degrees [-180, 180] - altitude: meters above WGS84 ellipsoid
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/position/position.py
49 50 51 52 53 54 55 56 57 58 59 60 61 | |
from_ds_metadata(ds)
classmethod
¶
Extract ECEF position from RINEX dataset metadata.
Reads from standard RINEX header attributes.
Parameters¶
ds : xr.Dataset RINEX dataset with position in attributes.
Returns¶
ECEFPosition Receiver position in ECEF.
Raises¶
KeyError If position attributes not found in dataset.
Examples¶
from canvod.readers import Rnxv3Obs rnx = Rnxv3Obs(fpath="station.24o") ds = rnx.to_ds() pos = ECEFPosition.from_ds_metadata(ds)
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/position/position.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
GeodeticPosition
dataclass
¶
Geodetic (WGS84) position.
Parameters¶
lat : float Latitude in degrees [-90, 90]. lon : float Longitude in degrees [-180, 180]. alt : float Altitude in meters above WGS84 ellipsoid.
Examples¶
pos = GeodeticPosition(lat=48.208, lon=16.373, alt=200.0) print(f"Vienna: {pos.lat}°N, {pos.lon}°E, {pos.alt}m")
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/position/position.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
to_ecef()
¶
Convert geodetic to ECEF coordinates.
Returns¶
ECEFPosition Position in ECEF frame.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/position/position.py
143 144 145 146 147 148 149 150 151 152 | |
add_broadcast_spherical_coords_to_dataset(ds, theta, phi)
¶
Add broadcast spherical coordinates to xarray Dataset.
Same convention as :func:add_spherical_coords_to_dataset but attrs
reflect that values come from the SBF broadcast navigation solution
rather than independently-computed SP3/CLK ephemerides.
Parameters¶
ds : xr.Dataset Dataset with 'epoch' and 'sid' dimensions. theta : np.ndarray Polar angles in radians [0, π]. phi : np.ndarray Azimuthal angles in radians [0, 2π).
Returns¶
xr.Dataset Dataset with phi and theta variables added.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/position/spherical_coords.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
add_spherical_coords_to_dataset(ds, r, theta, phi)
¶
Add spherical coordinates to xarray Dataset with proper metadata.
Parameters¶
ds : xr.Dataset Dataset with 'epoch' and 'sid' dimensions. r : np.ndarray Radial distances in meters. theta : np.ndarray Polar angles in radians [0, π]. phi : np.ndarray Azimuthal angles in radians [0, 2π).
Returns¶
xr.Dataset Dataset with phi, theta, r variables added.
Notes¶
Variables are added with CF-compliant attributes following physics convention.
Examples¶
After computing spherical coordinates¶
r, theta, phi = compute_spherical_coordinates(sat_x, sat_y, sat_z, rx_pos)
Add to RINEX dataset¶
augmented_ds = add_spherical_coords_to_dataset(rinex_ds, r, theta, phi) print(augmented_ds.phi.attrs['description'])
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/position/spherical_coords.py
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 | |
compute_spherical_coordinates(sat_x, sat_y, sat_z, rx_pos)
¶
Compute spherical coordinates (r, theta, phi) in navigation convention.
Uses local ENU (East-North-Up) topocentric frame centered at receiver.
Navigation Convention: - theta: Polar angle from +z axis (zenith), [0, π] radians * theta = 0 → zenith (straight up) * theta = π/2 → horizon * theta > π/2 → below horizon (set to NaN) - phi: Azimuthal angle from North, clockwise, [0, 2π) radians * phi = 0 → North * phi = π/2 → East * phi = π → South * phi = 3π/2 → West - r: Radial distance in meters
Note¶
The phi convention follows geographic/navigation standards where: - 0° points North (positive Y in ENU frame) - Angles increase clockwise when viewed from above - This is computed as arctan2(East, North), giving North=0° reference - Differs from physics convention which uses East=0° reference
Parameters¶
sat_x : np.ndarray Satellite X coordinates in ECEF (meters). sat_y : np.ndarray Satellite Y coordinates in ECEF (meters). sat_z : np.ndarray Satellite Z coordinates in ECEF (meters). rx_pos : ECEFPosition Receiver position in ECEF.
Returns¶
tuple[np.ndarray, np.ndarray, np.ndarray] (r, theta, phi) where: - r: distances in meters - theta: polar angles in radians [0, π] - phi: azimuthal angles in radians [0, 2π)
Notes¶
Satellites below horizon (theta > π/2) are set to NaN.
Examples¶
from canvod.auxiliary.position import ( ... ECEFPosition, compute_spherical_coordinates, ... )
Receiver position¶
rx = ECEFPosition(x=4194304.0, y=176481.0, z=4780013.0)
Satellite positions (example)¶
sat_x = np.array([16364123.0, 10205789.0]) sat_y = np.array([12123456.0, -8901234.0]) sat_z = np.array([18456789.0, 21234567.0])
r, theta, phi = compute_spherical_coordinates(sat_x, sat_y, sat_z, rx) print(f"Distance: {r[0]/1e6:.2f} Mm") print(f"Polar angle: {np.degrees(theta[0]):.1f}°") print(f"Azimuth: {np.degrees(phi[0]):.1f}°")
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/position/spherical_coords.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
Product Registry¶
Product registry and specifications for IGS analysis centers.
ProductSpec
¶
Bases: BaseModel
Product specification with structural validation.
Validates data structure only (fast). FTP availability validated during download (lazy, fail-fast).
Notes¶
This is a Pydantic BaseModel.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/products/registry_config.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
validate_prefix_matches_agency(v, info)
classmethod
¶
Validate prefix starts with agency code.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/products/registry_config.py
70 71 72 73 74 75 76 77 78 | |
get_product_spec(agency, product_type)
¶
Get product spec from global registry.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/products/registry_config.py
234 235 236 | |
list_agencies()
¶
List agencies from global registry.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/products/registry_config.py
239 240 241 | |
get_products_for_agency(agency)
¶
Get products for agency from global registry.
Source code in packages/canvod-auxiliary/src/canvod/auxiliary/products/registry_config.py
249 250 251 | |