Skip to content

Commit

Permalink
Check ionex (#74)
Browse files Browse the repository at this point in the history
* Add try loop

* All the ionex
  • Loading branch information
AlecThomson authored Jul 9, 2024
1 parent 78bfcc7 commit 459a8a3
Showing 1 changed file with 40 additions and 18 deletions.
58 changes: 40 additions & 18 deletions arrakis/frion.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from typing import Callable, Dict, List
from typing import NamedTuple as Struct
from typing import Optional, Union
from urllib.error import URLError

import astropy.units as u
import numpy as np
Expand Down Expand Up @@ -134,24 +135,45 @@ def predict_worker(
}
logger.info("Set up empty Proxy structure.")

times, RMs, theta = predict.calculate_modulation(
start_time=start_time.fits,
end_time=end_time.fits,
freq_array=freq,
telescope_location=predict.get_telescope_coordinates("ASKAP"),
ra=ra,
dec=dec,
timestep=300.0,
ionexPath=cutdir.parent / "IONEXdata",
server=server,
proxy_server=proxy_server,
use_proxy=True, # Always use proxy - forces urllib
prefix=prefix,
formatter=formatter,
pre_download=pre_download,
**proxy_args,
)
logger.info(f"Predicted modulation for {iname}.")
# Final solutions from CDDIS
_prefixes_to_try = [
prefix,
"codg",
"jplg",
"casg",
"esag",
"upcg",
"igsg",
]
for _prefix in _prefixes_to_try:
try:
times, RMs, theta = predict.calculate_modulation(
start_time=start_time.fits,
end_time=end_time.fits,
freq_array=freq,
telescope_location=predict.get_telescope_coordinates("ASKAP"),
ra=ra,
dec=dec,
timestep=300.0,
ionexPath=cutdir.parent / "IONEXdata",
server=server,
proxy_server=proxy_server,
use_proxy=True, # Always use proxy - forces urllib
prefix=_prefix,
formatter=formatter,
pre_download=pre_download,
**proxy_args,
)
break
except URLError:
logger.error(f"Could not find IONEX file with prefix '{_prefix}'")
logger.warning("Trying next prefix.")
continue
else:
raise FileNotFoundError(
f"Could not find IONEX file with prefixes {_prefixes_to_try}"
)

predict_file = os.path.join(i_dir, f"{iname}_ion.txt")
predict.write_modulation(freq_array=freq, theta=theta, filename=predict_file)
logger.info(f"Prediction file: {predict_file}")
Expand Down

0 comments on commit 459a8a3

Please sign in to comment.