morphfits.paths =============== .. py:module:: morphfits.paths .. autoapi-nested-parse:: Resolve, create, and otherwise handle directory and file structure for GalWrap. Attributes ---------- .. autoapisummary:: morphfits.paths.logger morphfits.paths.PATH_STANDARDS morphfits.paths.TEMPLATE_MAPPINGS morphfits.paths.MORPHFITS_PATHS Classes ------- .. autoapisummary:: morphfits.paths.MorphFITSPath Functions --------- .. autoapisummary:: morphfits.paths.get_path_obj morphfits.paths.get_directories morphfits.paths.get_files morphfits.paths.find_parameter_from_input morphfits.paths.get_path_name morphfits.paths.get_path Module Contents --------------- .. py:data:: logger Logging object for this module. .. py:data:: PATH_STANDARDS Path to data standard detailing paths for the MorphFITS filesystem structure. .. py:data:: TEMPLATE_MAPPINGS Dict mapping from template abbreviations to parameter names. .. py:class:: MorphFITSPath(/, **data: Any) Bases: :py:obj:`pydantic.BaseModel` Path model for a single path in the MorphFITS filesystem structure. :param BaseModel: Base pydantic model class to enforce type validation upon creation. :type BaseModel: class .. attribute:: file Flag for whether path is a file. :type: bool .. attribute:: path Path to object (directory or file) as a template, where other paths are wrapped by square brackets and parameters are wrapped by curly brackets, e.g. `[input_root]/{F}/{I}`. :type: str .. attribute:: alts List of recognized alternate names for this path. :type: list[sr] .. py:attribute:: file :type: bool .. py:attribute:: path :type: str .. py:attribute:: alts :type: list[str] .. py:method:: resolve(morphfits_root: pathlib.Path | None = None, input_root: pathlib.Path | None = None, output_root: pathlib.Path | None = None, product_root: pathlib.Path | None = None, run_root: pathlib.Path | None = None, field: str | None = None, image_version: str | None = None, catalog_version: str | None = None, filter: str | None = None, object: int | None = None, datetime: datetime.datetime | None = None, run_number: int | None = None) -> pathlib.Path | None Get the full path for this path object for passed configuration parameters. :param morphfits_root: Path to root of MorphFITS filesystem, by default None. :type morphfits_root: Path | None, optional :param input_root: Path to root input directory, by default None. :type input_root: Path | None, optional :param output_root: Path to root output directory, by default None. :type output_root: Path | None, optional :param product_root: Path to root products directory, by default None. :type product_root: Path | None, optional :param run_root: Path to root runs directory, by default None. :type run_root: Path | None, optional :param field: Field of observation, by default None. :type field: str | None, optional :param image_version: Image version of science frame, by default None. :type image_version: str | None, optional :param catalog_version: Catalog version of science frame, by default None. :type catalog_version: str | None, optional :param filter: Filter used in observation, by default None. :type filter: str | None, optional :param object: Target galaxy or cluster ID in catalog, by default None. :type object: int | None, optional :param datetime: Datetime at start of program run, by default None. :type datetime: datetime | None, optional :param run_number: Number of run in collection with same datetime, by default None. :type run_number: int | None, optional :returns: Full path to directory or file corresponding to this path object. :rtype: Path .. py:data:: MORPHFITS_PATHS Dict of paths used in MorphFITS, where the key, value pair is the path's `path_name`, then a `MorphFITSPath` instance. .. py:function:: get_path_obj(path_like: str | pathlib.Path) -> pathlib.Path Get a resolved Path object for a potential string. :param path_like: Path which may or may not be of string type. :type path_like: str | Path :returns: Corresponding Path object. :rtype: Path .. py:function:: get_directories(path: pathlib.Path) -> list[pathlib.Path] Get a list of subdirectories under a path. :param path: Path to be walked. :type path: Path :returns: List of subdirectories under specified path. :rtype: list[Path] :raises ValueError: Specified path not a directory. .. py:function:: get_files(path: pathlib.Path) -> list[pathlib.Path] Get a list of files in a directory. :param path: Path to be walked. :type path: Path :returns: List of files in specified directory. :rtype: list[Path] :raises ValueError: Specified path not a directory. .. py:function:: find_parameter_from_input(parameter_name: str, input_root: pathlib.Path) -> list[str] | list[int] Find values for a parameter, e.g. filters, from an input directory structure. :param parameter_name: Name of parameter, one of "field", "image_version", or "filter". Other parameters are not currently supported for discovery. :type parameter_name: str :param input_root: Path to root directory of input products. :type input_root: Path :returns: List of discovered parameter values. :rtype: list[str] | list[int] :raises ValueError: Unrecognized parameter name. .. py:function:: get_path_name(name: str) -> str Get internally-standardized name of path corresponding to passed name. :param name: Name of directory or file, e.g. `input_images`. :type name: str :returns: Corresponding standardized path name for internal usage. :rtype: str :raises TypeError: Passed name not a str. :raises ValueError: Passed name unrecognized. .. rubric:: Notes A path name is resolvable if its casefold is equal to 1. The standardized path name itself e.g `input_images` 2. A recognized alternative name e.g. `images` for `input_images` 3. The standardized path name, separated by spaces rather than underscores e.g. `input images` for `input_images` 4. The standardized path name, space-separated, with a corresponding `dir` or `file` suffix e.g. `input images dir` for `input_images` 5. The standardized path name, space-separated, suffixed, un-pluralized e.g. `input image dir` for `input_images` .. seealso:: :obj:`data` List of recognized alternative path names for each path. .. py:function:: get_path(name: str, morphfits_root: pathlib.Path | None = None, input_root: pathlib.Path | None = None, output_root: pathlib.Path | None = None, product_root: pathlib.Path | None = None, run_root: pathlib.Path | None = None, field: str | None = None, image_version: str | None = None, catalog_version: str | None = None, filter: str | None = None, object: int | None = None, datetime: datetime.datetime | None = None, run_number: int | None = None) -> pathlib.Path | None Get the path to a MorphFITS file or directory. :param name: Name of path to get. :type name: str :param morphfits_root: Path to root of MorphFITS filesystem, by default None. :type morphfits_root: Path | None, optional :param input_root: Path to root input directory, by default None. :type input_root: Path | None, optional :param output_root: Path to root output directory, by default None. :type output_root: Path | None, optional :param product_root: Path to root products directory, by default None. :type product_root: Path | None, optional :param run_root: Path to root runs directory, by default None. :type run_root: Path | None, optional :param field: Field of observation, by default None. :type field: str | None, optional :param image_version: Image version of science frame, by default None. :type image_version: str | None, optional :param catalog_version: Catalog version of science frame, by default None. :type catalog_version: str | None, optional :param filter: Filter used in observation, by default None. :type filter: str | None, optional :param object: Target galaxy or cluster ID in catalog, by default None. :type object: int | None, optional :param datetime: Datetime at start of program run, by default None. :type datetime: datetime | None, optional :param run_number: Number of run in collection with same datetime, by default None. :type run_number: int | None, optional :returns: Path to file or directory. :rtype: Path .. seealso:: :obj:`data` Data standards dictionary detailing MorphFITS paths.