Skip to content

canvod.filemap API reference

Package

canvod-filemap: naming recipes for non-canonical GNSS filenames.

VirtualFile dataclass

Physical file mapped to its canVOD conventional name.

canonical_str property

The conventional filename as a string.

open(mode='rb')

Open the physical file.

NamingRecipe

Bases: BaseModel

A user-defined mapping from arbitrary filenames to canVOD names.

Serialize to YAML for sharing, to JSON for API transport. Fields it does not know are ignored; :meth:unrecognized_fields names them.

expected_length property

Total number of characters consumed by the field spec.

parse_filename(filename)

Extract fields from a physical filename.

Parameters:

Name Type Description Default
filename str

Bare filename (no directory components).

required

Returns:

Type Description
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:

Type Description
ValueError

If the filename is too short for the field spec.

to_virtual_file(file_path)

Map a physical file to a VirtualFile using this recipe.

Parameters:

Name Type Description Default
file_path Path

Path to the physical file.

required

Returns:

Type Description
VirtualFile

The mapped virtual file.

Raises:

Type Description
ValueError

If the filename cannot be parsed.

matches(filename)

Check if a filename can be parsed by this recipe.

to_yaml()

Serialize to YAML string.

save(path)

Write recipe to a YAML file.

from_yaml(text) classmethod

Load from a YAML string.

Raises:

Type Description
YAMLError

If text is not YAML, or is nested too deeply to read.

ValidationError

If the YAML is not a valid recipe.

load(path) classmethod

Load from a YAML file.

unrecognized_fields(path) classmethod

Top-level fields of a recipe file that the recipe does not know.

They are ignored when the recipe is loaded, for example a misspelled field or one a later version of canvod-filemap reads.

Parameters:

Name Type Description Default
path Path

A recipe file.

required

Returns:

Type Description
list[str]

The unknown field names, in file order; empty if there are none.

Raises:

Type Description
YAMLError

If the file is not YAML, or is nested too deeply to read.

RecipeNotFoundError

Bases: FileNotFoundError

No recipe file exists for a site and recipe name.

RecipeFetchError

Bases: RemoteRecipeError

A recipe that could not be fetched, or whose file is not a valid recipe.

RecipeURLError

Bases: RemoteRecipeError, ValueError

A recipe URL that is not a raw file link.

RemoteRecipeError

Bases: Exception

A recipe URL that cannot be used.

recipe_sha256(path)

The sha256 of a recipe file, as recorded in a store's metadata.

Parameters:

Name Type Description Default
path Path

A recipe file, local or fetched by this run.

required

Returns:

Type Description
str

The hexadecimal sha256 of the file's bytes.

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:

Name Type Description Default
config_dir Path

The configuration directory (the one holding the settings file).

required
site str

Site name in the settings file.

required
name str

Recipe name, the receiver's recipe: setting.

required
overwrite bool

Replace an existing recipe file.

False

Returns:

Type Description
Path

The created file, <config_dir>/recipes/<site>/<name>.yaml.

Raises:

Type Description
FileExistsError

If the recipe file exists and overwrite is false.

find_recipe(config_dir, site, name)

Path of the existing recipe file name of site.

Parameters:

Name Type Description Default
config_dir Path

The configuration directory (the one holding the settings file).

required
site str

Site name in the settings file.

required
name str

Recipe name, the receiver's recipe: setting.

required

Returns:

Type Description
Path

<config_dir>/recipes/<site>/<name>.yaml, or, if name is a URL, the file of the recipe this run fetched (:func:canvod.filemap.remote.fetch_recipe).

Raises:

Type Description
RecipeNotFoundError

If that file does not exist. If the recipe is found directly in <config_dir>/recipes/, the message says where to move it.

RemoteRecipeError

If name is a URL that is not a raw file link, or the recipe cannot be fetched or is not valid.

recipe_path(config_dir, site, name)

Path of the recipe name of site, whether it exists or not.

Parameters:

Name Type Description Default
config_dir Path

The configuration directory (the one holding the settings file).

required
site str

Site name in the settings file.

required
name str

Recipe name, the receiver's recipe: setting.

required

Returns:

Type Description
Path

<config_dir>/recipes/<site>/<name>.yaml.

check_recipe_url(url)

Check that url is a raw file link in a GitHub repository.

Parameters:

Name Type Description Default
url str

The recipe URL.

required

Raises:

Type Description
RecipeURLError

If the URL is not https, holds a user name, password, query or fragment, points to a host other than raw.githubusercontent.com (a github.com/.../blob/... link gets the matching raw link), has no <account>/<repo>/<commit, tag or branch>/<file> path, or does not end in a .yaml or .yml file.

fetch_recipe(url, *, timeout=30.0)

The local file of the recipe at url, fetched by this run.

The URL is checked with :func:check_recipe_url. The file is fetched, read like a local recipe file, and its name must match the file name at the end of the URL. A run fetches a URL once, into a folder of the run that is removed when the process that made it ends (:func:canvod.utils.remote_file.fetch_remote).

Parameters:

Name Type Description Default
url str

The recipe URL.

required
timeout float

Seconds to wait for the server.

30.0

Returns:

Type Description
Path

The fetched recipe file.

Raises:

Type Description
RecipeURLError

If the URL is not a raw file link.

RecipeFetchError

If the file cannot be fetched (not found, no access, a token that is not a token, no network, timeout), is not a valid recipe, or its name does not match the URL.

is_recipe_url(value)

Whether a recipe: setting is a URL rather than a recipe name.

Parameters:

Name Type Description Default
value str

The receiver's recipe: setting.

required

Returns:

Type Description
bool

True for https:// and http:// values.

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

  • year 4-digit year (e.g. 2025)
  • yy 2-digit year (80-99 → 19xx, 00-79 → 20xx)
  • doy day of year (1-366)
  • month month (01-12)
  • day day of month (01-31)
  • hour hour (00-23)
  • minute minute (00-59)
  • hour_letter RINEX 2 session letter (a-x = hours 0-23; 0 = daily file)
  • skip ignore these characters

Example recipe (YAML)

::

name: fangorn_reference
description: Orthanc, reference receiver

site: FAN
agency: INK
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. Fields it does not know are ignored; :meth:unrecognized_fields names them.

expected_length property

Total number of characters consumed by the field spec.

parse_filename(filename)

Extract fields from a physical filename.

Parameters:

Name Type Description Default
filename str

Bare filename (no directory components).

required

Returns:

Type Description
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:

Type Description
ValueError

If the filename is too short for the field spec.

to_virtual_file(file_path)

Map a physical file to a VirtualFile using this recipe.

Parameters:

Name Type Description Default
file_path Path

Path to the physical file.

required

Returns:

Type Description
VirtualFile

The mapped virtual file.

Raises:

Type Description
ValueError

If the filename cannot be parsed.

matches(filename)

Check if a filename can be parsed by this recipe.

to_yaml()

Serialize to YAML string.

save(path)

Write recipe to a YAML file.

from_yaml(text) classmethod

Load from a YAML string.

Raises:

Type Description
YAMLError

If text is not YAML, or is nested too deeply to read.

ValidationError

If the YAML is not a valid recipe.

load(path) classmethod

Load from a YAML file.

unrecognized_fields(path) classmethod

Top-level fields of a recipe file that the recipe does not know.

They are ignored when the recipe is loaded, for example a misspelled field or one a later version of canvod-filemap reads.

Parameters:

Name Type Description Default
path Path

A recipe file.

required

Returns:

Type Description
list[str]

The unknown field names, in file order; empty if there are none.

Raises:

Type Description
YAMLError

If the file is not YAML, or is nested too deeply to read.

recipe_sha256(path)

The sha256 of a recipe file, as recorded in a store's metadata.

Parameters:

Name Type Description Default
path Path

A recipe file, local or fetched by this run.

required

Returns:

Type Description
str

The hexadecimal sha256 of the file's bytes.

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.

recipe_path(config_dir, site, name)

Path of the recipe name of site, whether it exists or not.

Parameters:

Name Type Description Default
config_dir Path

The configuration directory (the one holding the settings file).

required
site str

Site name in the settings file.

required
name str

Recipe name, the receiver's recipe: setting.

required

Returns:

Type Description
Path

<config_dir>/recipes/<site>/<name>.yaml.

find_recipe(config_dir, site, name)

Path of the existing recipe file name of site.

Parameters:

Name Type Description Default
config_dir Path

The configuration directory (the one holding the settings file).

required
site str

Site name in the settings file.

required
name str

Recipe name, the receiver's recipe: setting.

required

Returns:

Type Description
Path

<config_dir>/recipes/<site>/<name>.yaml, or, if name is a URL, the file of the recipe this run fetched (:func:canvod.filemap.remote.fetch_recipe).

Raises:

Type Description
RecipeNotFoundError

If that file does not exist. If the recipe is found directly in <config_dir>/recipes/, the message says where to move it.

RemoteRecipeError

If name is a URL that is not a raw file link, or the recipe cannot be fetched or is not valid.

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:

Name Type Description Default
config_dir Path

The configuration directory (the one holding the settings file).

required
site str

Site name in the settings file.

required
name str

Recipe name, the receiver's recipe: setting.

required
overwrite bool

Replace an existing recipe file.

False

Returns:

Type Description
Path

The created file, <config_dir>/recipes/<site>/<name>.yaml.

Raises:

Type Description
FileExistsError

If the recipe file exists and overwrite is false.

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.

canonical_str property

The conventional filename as a string.

open(mode='rb')

Open the physical file.

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:

Type Description
ValueError

If the letter is not a valid RINEX hour code.

resolve_year_from_yy(yy)

Expand a 2-digit year to 4 digits (80-99 → 1980-1999, 00-79 → 2000-2079).