From 58006a35619b70730b24ab21bf43ec452e351e07 Mon Sep 17 00:00:00 2001 From: Andrew Cleland Date: Thu, 11 Apr 2024 20:23:35 +1000 Subject: [PATCH 1/3] Use auto_download_PPP function in gn module This function achieves the same result, so it's worth just using this one --- scripts/gn/download_rinex_deps.py | 117 ++++++++++++------------------ 1 file changed, 47 insertions(+), 70 deletions(-) diff --git a/scripts/gn/download_rinex_deps.py b/scripts/gn/download_rinex_deps.py index 4aa4b4104..af768f6e7 100644 --- a/scripts/gn/download_rinex_deps.py +++ b/scripts/gn/download_rinex_deps.py @@ -12,9 +12,15 @@ from .parse_rinex_header import RinexHeader import pandas as pd -from gnssanalysis.filenames import generate_IGS_long_filename -from gnssanalysis.gn_download import download_multiple_files_from_cddis -from gnssanalysis.gn_datetime import dt2gpswk +# This import is a hack to allow the import of auto_download_PPP from the +# parent directory. Some options to refactor: +# 1. Move the code from this module into the parent directory and make it like any other script +# 2. Move the auto_download code that this module depends on into gnssanalysis +# 3. Leave it like this for now +import sys +sys.path.append("..") + +from auto_download_PPP import auto_download def download(header: RinexHeader, target_dir: Path) -> None: @@ -25,7 +31,8 @@ def download(header: RinexHeader, target_dir: Path) -> None: :param target_dir: Path to the target directory """ start_date = pd.to_datetime(header.first_obs_time).date() - end_date = pd.to_datetime(header.last_obs_time).date() + # Add one day because auto_download does not allow the same date to be given as start and end + end_date = pd.to_datetime(header.last_obs_time).date() + pd.Timedelta("1 day") _download_static_dependencies(start_date, end_date, target_dir) @@ -36,72 +43,42 @@ def _download_static_dependencies(start_date: _date, end_date: _date, target_dir :param end_date: Last date to download for :param target_dir: Target directory to download files to """ - for date in daterange(start_date, end_date): - files = _get_static_long_filenames(date) - - gps_week = dt2gpswk(date) - ftp_folder = f"gnss/products/{gps_week}" - - download_multiple_files_from_cddis(files, ftp_folder, target_dir) - - -def _get_static_long_filenames(date: _date) -> [str]: - """Deterimines the long filenames for sp3, erp and clk files for a given date, - which will allow ginan to run ppp static. - - :param date: Date to determine filenames for - :returns [str] of filenames - """ - # TODO: Support more than just IGS FIN products - - # Weekly files - week = timedelta(7) - - def _first_day_of_week(date: _date): - return date + timedelta(days=-(date.weekday() + 1)) - - first_day_of_week = _first_day_of_week(date) - erp_filename = generate_IGS_long_filename( + auto_download( + target_dir, + preset=None, + station_list=None, + start_datetime=start_date.strftime("%Y-%m-%d"), + end_datetime=end_date.strftime("%Y-%m-%d"), + replace=True, + dont_replace=False, + most_recent=False, analysis_center="IGS", - content_type="ERP", - format_type="ERP", - start_epoch=first_day_of_week, - timespan=week, + atx=False, + aload=False, + igrf=False, + egm=False, + oload=False, + opole=False, + fes=False, + planet=False, + sat_meta=False, + yaw=False, + snx=False, + nav=False, + sp3=True, + erp=True, + clk=True, + bia=False, + gpt2=False, + rinex_data_dir=None, + trop_dir=None, + model_dir=None, solution_type="FIN", - sampling_rate="01D", - project="OPS", + project_type="OPS", + rinex_file_period=None, + bia_ac=None, + iau2000=False, + datetime_format="%Y-%m-%d", + data_source=None, + verbose=True, ) - - # Daily files - day = timedelta(1) - sp3_filename = generate_IGS_long_filename( - analysis_center="IGS", - content_type="ORB", - format_type="SP3", - start_epoch=date, - timespan=day, - solution_type="FIN", - sampling_rate="15M", - project="OPS", - ) - - clk_filename = generate_IGS_long_filename( - analysis_center="IGS", - content_type="CLK", - format_type="CLK", - start_epoch=date, - timespan=day, - solution_type="FIN", - sampling_rate="05M", - project="OPS", - ) - - files = [erp_filename, sp3_filename, clk_filename] - compressed_files = [f + ".gz" for f in files] - return compressed_files - - -def daterange(start_date: _date, end_date: _date = None): - """Generator for dates between start and end""" - for i in range(int((end_date - start_date).days) + 1): - yield start_date + timedelta(i) From d262e8bb51da5a6337bb38220df0f8ddfce87427 Mon Sep 17 00:00:00 2001 From: Andrew Cleland Date: Thu, 11 Apr 2024 20:31:08 +1000 Subject: [PATCH 2/3] Fix paths to dependencies in template --- scripts/gn/templates/auto_template.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/gn/templates/auto_template.yaml b/scripts/gn/templates/auto_template.yaml index 5877483e6..3c64525be 100644 --- a/scripts/gn/templates/auto_template.yaml +++ b/scripts/gn/templates/auto_template.yaml @@ -9,10 +9,10 @@ inputs: planetary_ephemeris_files: [ ../../inputData/products/tables/DE436.1950.2050 ] troposphere: - gpt2grid_files: [ ../../inputData/products/gpt_25.grd ] + gpt2grid_files: [ ../../inputData/products/tables/gpt_25.grd ] tides: - ocean_tide_loading_blq_files: [ ../../inputData/products/OLOAD_GO.BLQ ] # required if ocean loading is applied + ocean_tide_loading_blq_files: [ ../../inputData/products/tables/OLOAD_GO.BLQ ] # required if ocean loading is applied ocean_tide_potential_files: [ ../../inputData/products/tables/fes2014b_Cnm-Snm.dat ] snx_files: [ "./downloads/*.SNX" ] From fcec7c4dccc14a60d1a83e4e2bfc533f79807ba8 Mon Sep 17 00:00:00 2001 From: Andrew Cleland Date: Thu, 11 Apr 2024 20:31:31 +1000 Subject: [PATCH 3/3] Add missing georinex dependency georinex is used in gn module to parse rinex, it was missing from requirements.txt --- scripts/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/requirements.txt b/scripts/requirements.txt index 25c999fb4..e78529787 100644 --- a/scripts/requirements.txt +++ b/scripts/requirements.txt @@ -22,3 +22,4 @@ scipy>=1.7.3 statsmodels>=0.13.2 hatanaka>=2.8.1 gnssanalysis>=0.0.28 +git+https://github.com/breid-phys/georinex.git # fast processing patch - not yet merged into georinex https://github.com/geospace-code/georinex/pull/85