Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes to gn module #86

Open
wants to merge 3 commits into
base: develop-weekly
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 47 additions & 70 deletions scripts/gn/download_rinex_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)


Expand All @@ -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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll probably want to have this one on? Unless you grab this file from elsewhere?

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)
4 changes: 2 additions & 2 deletions scripts/gn/templates/auto_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Expand Down
1 change: 1 addition & 0 deletions scripts/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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