canvod.filemap API Reference¶
Package¶
canvod-filemap: naming recipes for non-canonical GNSS filenames.
VirtualFile
dataclass
¶
Physical file mapped to its canVOD conventional name.
Source code in packages/canvod-filemap/src/canvod/filemap/mapping.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | |
NamingRecipe
¶
Bases: BaseModel
A user-defined mapping from arbitrary filenames to canVOD names.
Serialize to YAML for sharing, to JSON for API transport.
Source code in packages/canvod-filemap/src/canvod/filemap/recipe.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 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 343 344 345 | |
expected_length
property
¶
Total number of characters consumed by the field spec.
parse_filename(filename)
¶
Extract fields from a physical filename.
Parameters¶
filename Bare filename (no directory components).
Returns¶
dict
Extracted field values. Integer fields (year, doy, etc.) are
returned as int. hour_letter is returned as str.
skip fields are not included.
Raises¶
ValueError If the filename is too short for the field spec.
Source code in packages/canvod-filemap/src/canvod/filemap/recipe.py
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 | |
to_virtual_file(file_path)
¶
Map a physical file to a VirtualFile using this recipe.
Parameters¶
file_path Path to the physical file.
Returns¶
VirtualFile The mapped virtual file.
Raises¶
ValueError If the filename cannot be parsed.
Source code in packages/canvod-filemap/src/canvod/filemap/recipe.py
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 | |
matches(filename)
¶
Check if a filename can be parsed by this recipe.
Source code in packages/canvod-filemap/src/canvod/filemap/recipe.py
309 310 311 312 313 314 315 316 317 | |
to_yaml()
¶
Serialize to YAML string.
Source code in packages/canvod-filemap/src/canvod/filemap/recipe.py
321 322 323 324 325 326 327 328 | |
save(path)
¶
Write recipe to a YAML file.
Source code in packages/canvod-filemap/src/canvod/filemap/recipe.py
330 331 332 333 | |
from_yaml(text)
classmethod
¶
Load from a YAML string.
Source code in packages/canvod-filemap/src/canvod/filemap/recipe.py
335 336 337 338 339 | |
load(path)
classmethod
¶
Load from a YAML file.
Source code in packages/canvod-filemap/src/canvod/filemap/recipe.py
341 342 343 344 345 | |
RecipeNotFoundError
¶
Bases: FileNotFoundError
No recipe file exists for a site and recipe name.
Source code in packages/canvod-filemap/src/canvod/filemap/recipe_files.py
20 21 | |
create_recipe(config_dir, site, name, *, overwrite=False)
¶
Create the recipe name of site from the template.
The new file has name filled in. The receiver identity and the
fields list must be edited before the recipe can be loaded.
Parameters¶
config_dir : Path
The configuration directory (the one holding the settings file).
site : str
Site name in the settings file.
name : str
Recipe name, the receiver's recipe: setting.
overwrite : bool
Replace an existing recipe file.
Returns¶
Path
The created file, <config_dir>/recipes/<site>/<name>.yaml.
Raises¶
FileExistsError
If the recipe file exists and overwrite is false.
Source code in packages/canvod-filemap/src/canvod/filemap/recipe_files.py
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 | |
find_recipe(config_dir, site, name)
¶
Path of the existing recipe file name of site.
Parameters¶
config_dir : Path
The configuration directory (the one holding the settings file).
site : str
Site name in the settings file.
name : str
Recipe name, the receiver's recipe: setting.
Returns¶
Path
<config_dir>/recipes/<site>/<name>.yaml.
Raises¶
RecipeNotFoundError
If that file does not exist. If the recipe is found directly in
<config_dir>/recipes/, the message says where to move it.
Source code in packages/canvod-filemap/src/canvod/filemap/recipe_files.py
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 | |
recipe_path(config_dir, site, name)
¶
Path of the recipe name of site, whether it exists or not.
Parameters¶
config_dir : Path
The configuration directory (the one holding the settings file).
site : str
Site name in the settings file.
name : str
Recipe name, the receiver's recipe: setting.
Returns¶
Path
<config_dir>/recipes/<site>/<name>.yaml.
Source code in packages/canvod-filemap/src/canvod/filemap/recipe_files.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
Recipe¶
Naming recipe: user-defined mapping from arbitrary filenames to canVOD names.
A recipe is a small YAML file that describes: 1. The canonical identity of a receiver (site, agency, sampling, etc.) 2. How to extract date/time fields from the user's physical filenames.
The field extraction is a sequential left-to-right walk over the filename.
Each entry in the fields list consumes characters and either extracts
a named value or skips literal characters.
Recognized field names¶
year4-digit year (e.g. 2025)yy2-digit year (80-99 → 19xx, 00-79 → 20xx)doyday of year (1-366)monthmonth (01-12)dayday of month (01-31)hourhour (00-23)minuteminute (00-59)hour_letterRINEX 2 session letter (a-x = hours 0-23; 0 = daily file)skipignore these characters
Example recipe (YAML)¶
::
name: rosalia_reference
description: Rosalia forest, reference receiver
site: ROS
agency: TUW
receiver_number: 1
receiver_type: reference
sampling: "05S"
period: "15M"
content: "AA"
file_type: rnx
glob: "*.??o"
# Example: rref001a15.25o
fields:
- skip: 4
- doy: 3
- hour_letter: 1
- minute: 2
- skip: 1
- yy: 2
- skip: 1
Example recipe for exotic filenames¶
::
# Example: STATION_2025_042_00_15.rinex
fields:
- skip: 8
- year: 4
- skip: 1
- doy: 3
- skip: 1
- hour: 2
- skip: 1
- minute: 2
- skip: 6
NamingRecipe
¶
Bases: BaseModel
A user-defined mapping from arbitrary filenames to canVOD names.
Serialize to YAML for sharing, to JSON for API transport.
Source code in packages/canvod-filemap/src/canvod/filemap/recipe.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 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 343 344 345 | |
expected_length
property
¶
Total number of characters consumed by the field spec.
parse_filename(filename)
¶
Extract fields from a physical filename.
Parameters¶
filename Bare filename (no directory components).
Returns¶
dict
Extracted field values. Integer fields (year, doy, etc.) are
returned as int. hour_letter is returned as str.
skip fields are not included.
Raises¶
ValueError If the filename is too short for the field spec.
Source code in packages/canvod-filemap/src/canvod/filemap/recipe.py
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 | |
to_virtual_file(file_path)
¶
Map a physical file to a VirtualFile using this recipe.
Parameters¶
file_path Path to the physical file.
Returns¶
VirtualFile The mapped virtual file.
Raises¶
ValueError If the filename cannot be parsed.
Source code in packages/canvod-filemap/src/canvod/filemap/recipe.py
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 | |
matches(filename)
¶
Check if a filename can be parsed by this recipe.
Source code in packages/canvod-filemap/src/canvod/filemap/recipe.py
309 310 311 312 313 314 315 316 317 | |
to_yaml()
¶
Serialize to YAML string.
Source code in packages/canvod-filemap/src/canvod/filemap/recipe.py
321 322 323 324 325 326 327 328 | |
save(path)
¶
Write recipe to a YAML file.
Source code in packages/canvod-filemap/src/canvod/filemap/recipe.py
330 331 332 333 | |
from_yaml(text)
classmethod
¶
Load from a YAML string.
Source code in packages/canvod-filemap/src/canvod/filemap/recipe.py
335 336 337 338 339 | |
load(path)
classmethod
¶
Load from a YAML file.
Source code in packages/canvod-filemap/src/canvod/filemap/recipe.py
341 342 343 344 345 | |
Recipe Files¶
Where naming recipe files live, and creating them from the template.
Recipes are kept per site in the configuration directory::
<config dir>/recipes/<site>/<name>.yaml
<site> is the site name in the settings file and <name> the
receiver's recipe: setting. Recipe files are user data: they are not part
of any repository and are only read from this location.
RecipeNotFoundError
¶
Bases: FileNotFoundError
No recipe file exists for a site and recipe name.
Source code in packages/canvod-filemap/src/canvod/filemap/recipe_files.py
20 21 | |
recipe_path(config_dir, site, name)
¶
Path of the recipe name of site, whether it exists or not.
Parameters¶
config_dir : Path
The configuration directory (the one holding the settings file).
site : str
Site name in the settings file.
name : str
Recipe name, the receiver's recipe: setting.
Returns¶
Path
<config_dir>/recipes/<site>/<name>.yaml.
Source code in packages/canvod-filemap/src/canvod/filemap/recipe_files.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
find_recipe(config_dir, site, name)
¶
Path of the existing recipe file name of site.
Parameters¶
config_dir : Path
The configuration directory (the one holding the settings file).
site : str
Site name in the settings file.
name : str
Recipe name, the receiver's recipe: setting.
Returns¶
Path
<config_dir>/recipes/<site>/<name>.yaml.
Raises¶
RecipeNotFoundError
If that file does not exist. If the recipe is found directly in
<config_dir>/recipes/, the message says where to move it.
Source code in packages/canvod-filemap/src/canvod/filemap/recipe_files.py
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 | |
create_recipe(config_dir, site, name, *, overwrite=False)
¶
Create the recipe name of site from the template.
The new file has name filled in. The receiver identity and the
fields list must be edited before the recipe can be loaded.
Parameters¶
config_dir : Path
The configuration directory (the one holding the settings file).
site : str
Site name in the settings file.
name : str
Recipe name, the receiver's recipe: setting.
overwrite : bool
Replace an existing recipe file.
Returns¶
Path
The created file, <config_dir>/recipes/<site>/<name>.yaml.
Raises¶
FileExistsError
If the recipe file exists and overwrite is false.
Source code in packages/canvod-filemap/src/canvod/filemap/recipe_files.py
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 | |
Mapping¶
VirtualFile: a physical file paired with its canVOD conventional name.
NamingRecipe.to_virtual_file returns it; the file on disk keeps its name.
VirtualFile
dataclass
¶
Physical file mapped to its canVOD conventional name.
Source code in packages/canvod-filemap/src/canvod/filemap/mapping.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | |
Patterns¶
Helpers for the date and time fields of non-canonical filenames.
hour_letter_to_int(letter)
¶
Convert a RINEX hour letter (a-x or '0') to an integer 0-23.
Raises¶
ValueError If the letter is not a valid RINEX hour code.
Source code in packages/canvod-filemap/src/canvod/filemap/patterns.py
10 11 12 13 14 15 16 17 18 19 20 21 | |
resolve_year_from_yy(yy)
¶
Expand a 2-digit year to 4 digits (80-99 → 1980-1999, 00-79 → 2000-2079).
Source code in packages/canvod-filemap/src/canvod/filemap/patterns.py
24 25 26 27 28 | |