Skip to content
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
2 changes: 1 addition & 1 deletion maven_iuvs/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def get_default_data_directory(level='l1b'):
elif level == 'l1a_full_mission_reprocess':
local_dir = l1a_full_mission_reprocess_dir
else:
raise ValueError("level must be 'l1a' or 'l1b'")
raise ValueError("level must be 'l1a' or 'l1b' or 'l1a_full_mission_reprocess'")

if not os.path.exists(local_dir):
raise Exception("Cannot find specified directory: "
Expand Down
6 changes: 3 additions & 3 deletions maven_iuvs/echelle.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
from maven_iuvs.geometry import has_geometry_pvec
from maven_iuvs.search import get_latest_files, find_files
from maven_iuvs.integration import get_avg_pixel_count_rate
from maven_iuvs.download import get_default_data_directory
from statistics import median_high
from maven_iuvs.user_paths import l1a_dir
from statsmodels.tools.numdiff import approx_hess1, approx_hess2, approx_hess3
from numpy.linalg import inv
import dynesty as d
Expand Down Expand Up @@ -418,7 +418,7 @@ def make_light_and_dark_pair_CSV(ech_l1a_idx, dark_index, l1a_dir, csv_path="lig
orbit_num = iuvs_orbno_from_fname(lightfn)
try:
darkfn = lights_and_darks[k][1]["name"]
wr.writerow([l1a_dir + orbit_folder(orbit_num) + "/",
wr.writerow([get_default_data_directory('l1a') + orbit_folder(orbit_num) + "/",
lightfn,
darkfn,
label])
Expand Down Expand Up @@ -495,7 +495,7 @@ def get_dark(light_filepath, idx, drkidx):
return "No valid dark"
# raise Exception("No pair identified but it's also not a file missing dark??")

thedarkpath = f"{l1a_dir}{orbfolder}/{lights_and_darks[justfn][1]['name']}"
thedarkpath = f"{get_default_data_directory('l1a')}{orbfolder}/{lights_and_darks[justfn][1]['name']}"

return thedarkpath

Expand Down
6 changes: 3 additions & 3 deletions maven_iuvs/graphics/echelle_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
iuvs_segment_from_fname, get_n_int, iuvs_filename_to_datetime, fn_noext_RE, fn_RE
from maven_iuvs.search import find_files
from maven_iuvs.time import utc_to_sol
from maven_iuvs.user_paths import l1a_dir
from maven_iuvs.download import get_default_data_directory

# COMMON COLORS ==========================================================================================
model_color = "#1b9e77"
Expand Down Expand Up @@ -93,11 +93,11 @@ def run_quicklooks(ech_l1a_idx, date=None, orbit=None, segment=None, start_k=0,
light_idx = lights_and_darks[k][0]

# open the light file --------------------------------------------------------------------
light_path = find_files(data_directory=l1a_dir,
light_path = find_files(data_directory=get_default_data_directory('l1a'),
use_index=False, pattern=light_idx['name'])[0]

# open the dark file ---------------------------------------------------------------------
dark_path = find_files(data_directory=l1a_dir,
dark_path = find_files(data_directory=get_default_data_directory('l1a'),
use_index=False, pattern=lights_and_darks[k][1]["name"])[0]

quicklook_status = ""
Expand Down
6 changes: 3 additions & 3 deletions maven_iuvs/miscellaneous.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import datetime
import re
import os
from maven_iuvs.user_paths import l1a_dir, l1a_full_mission_reprocess_dir

# Common regular expressions for parsing filenames
orbit_set_RE = r"(?<=/orbit)[0-9]{5}(?=/)"
Expand Down Expand Up @@ -236,10 +235,11 @@ def relative_path_from_fname(l1a_fname, v="v13"):

# Get orbit folder
orbfold = orbit_folder(iuvs_orbno_from_fname(l1a_fname))
from maven_iuvs.download import get_default_data_directory
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe imports are required to be at the top of the file or it will throw an error

Copy link
Collaborator

Choose a reason for hiding this comment

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

It needs to be here to avoid a circular import error, but this should be explicitly noted with a comment rather than implied.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, you can also import the download.py module as an alias, like:

# miscellaneous.py:

import maven_iuvs.download as dl
...
blah = dl.get_default_data_directory('l1a')

But this is not the most elegant since it imports the whole module. At any rate, I have something like this in echelle.py and echelle_graphics.py to avoid the same problem, but that's probably better addressed by eventually splitting up the quicklook vs. line fitting codes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

To clarify, @JadenStrom please add either a comment to explain the positioning, or use the tactic I showed above. Make a new commit, push to origin, and it should show up here.

if v=="v13":
return l1a_dir + orbfold + "/"
return get_default_data_directory('l1a') + orbfold + "/"
elif v=="v14":
return l1a_full_mission_reprocess_dir + orbfold + "/"
return get_default_data_directory('l1a_full_mission_reprocess') + orbfold + "/"
else:
raise Exception("Invalid version number for data products! Please choose 'v13' or 'v14'")

Expand Down