gnssrefl.utils module

class gnssrefl.utils.FileManagement(station, file_type, year: int = None, doy: int = None, file_not_found_ok: bool = False, frequency: int = None, extension: str = '')

Bases: object

FileManagement is designed to easily read the files that this package relies on. Required parameters include station and file_type from FileTypes class. Optional parameters are year, doy, and file_not_found_ok.

find_apriori_rh_file()

Find apriori RH file with backwards compatibility fallback.

Search order: 1. New format: input/{station}/[{extension}/]{station}_phaseRH_L{freq}.txt 2. Legacy fallback: input/{station}_phaseRH[_L1|_L5].txt (L2 has no suffix)

Returns:

(Path, str) - (file_path, format_type)

format_type: ‘new_format’, ‘legacy’

Return type:

tuple

find_daily_avg_phase_file()

Find daily average phase file with backwards compatibility fallback.

Search order: - No extension:

  1. Files/{station}/{station}_phase.txt (new format)

  2. Files/{station}_phase.txt (legacy fallback)

  • With extension: 1. Files/{station}/{extension}/{station}_phase.txt (new format) 2. Files/{station}_phase.txt (legacy fallback - no extension separation in legacy)

Returns: (Path, str) - (file_path, format_type)

find_json_file()

Find JSON file with backwards compatibility fallback.

Search order (no cross-priority): - No extension:

  1. input/{station}/{station}.json (new format)

  2. input/{station}.json (legacy fallback)

  • With extension: 1. input/{station}/{extension}/{station}.json (new format) 2. input/{station}.{extension}.json (legacy fallback)

Returns: (Path, str) - (file_path, format_type)

find_volumetric_water_content_file()

Find volumetric water content file with backwards compatibility fallback.

Search order: - No extension:

  1. Files/{station}/{station}_vwc.txt (new format)

  2. Files/{station}_vwc.txt (legacy fallback)

  • With extension: 1. Files/{station}/{extension}/{station}_vwc.txt (new format) 2. Files/{station}_vwc.txt (legacy fallback - no extension separation in legacy)

Returns: (Path, str) - (file_path, format_type)

get_directory_path(ensure_directory=True)

Get the path of a specific directory from the FileTypes class.

Parameters:

ensure_directory (bool, optional) – If True, creates the directory if it doesn’t exist. Default is True.

Returns:

Directory path requested as a Path object

Return type:

Path

get_file_path(ensure_directory=True)

Get the path of a specific file from the FileTypes class.

Parameters:

ensure_directory (bool, optional) – If True, creates the parent directory if it doesn’t exist. Default is True.

Returns:

File path requested as a Path object

Return type:

Path

read_file(transpose=False, **kwargs)

Reads the requested file amd returns results of file as an array. Can use transpose parameter to transpose the results.

class gnssrefl.utils.FileTypes(value)

Bases: str, Enum

Files to either read from or save to.

apriori_rh_file = 'apriori_rh_file'
arcs_directory = 'arcs_directory'
daily_avg_phase_results = 'daily_avg_phase_results'
directory = 'directory'
make_json = 'make_json'
phase_file = 'phase_file'
volumetric_water_content = 'volumetric_water_content'
gnssrefl.utils.check_environment()
gnssrefl.utils.get_sys()
gnssrefl.utils.read_files_in_dir(directory, transpose=False)

Read all files in a given directory. Directory given must be an absolute path. Returns an n-d array of results. Can use optional parameter transpose to transpose the results.

gnssrefl.utils.set_environment(refl_code, orbits, exe)
gnssrefl.utils.str2bool(args, expected_bools)
gnssrefl.utils.validate_input_datatypes(obj, **kwargs)