Skip to content

Commit

Permalink
Merge pull request #365 from nasa-fornax/raen/spectra_generator/cleanup
Browse files Browse the repository at this point in the history
Minor bug fixes for spectra_generator
  • Loading branch information
bsipocz authored Dec 13, 2024
2 parents 0e0cb9a + 5bfe3e1 commit 260dbfc
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
6 changes: 5 additions & 1 deletion spectroscopy/code_src/plot_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ def create_figures(df_spec, bin_factor, show_nbr_figures, save_output):
Whether to save the figures. If saved, they will be in the "output" directory.
"""

output_dir = 'output'
if save_output and not os.path.exists(output_dir):
os.mkdir(output_dir)

for cc, (objectid, singleobj_df) in enumerate(df_spec.data.groupby('objectid')):

fig = plt.figure(figsize=(9, 6))
Expand Down Expand Up @@ -151,7 +155,7 @@ def create_figures(df_spec, bin_factor, show_nbr_figures, save_output):
ax1.legend(bbox_to_anchor=(1.27, 1), fontsize=11)

if save_output:
savename = os.path.join("output", "spectra_{}.pdf".format(objectid))
savename = os.path.join(output_dir, "spectra_{}.pdf".format(objectid))
plt.savefig(savename, bbox_inches="tight")

if cc < show_nbr_figures:
Expand Down
8 changes: 8 additions & 0 deletions spectroscopy/data/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Data - Spectroscopy

This directory is used for data that is downloaded or otherwise retrieved for the spectroscopy use case. Users may
also store additional data here. Note that there is a separate directory for output generated by the notebooks or
its users.

Data should not be committed to the code repository. This directory is included in the .gitignore file to prevent
accidental commits.
7 changes: 7 additions & 0 deletions spectroscopy/output/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Output - Spectroscopy

This directory is used for output generated by the spectroscopy use case. This includes results, figures, logs,
etc. Users may also store their own output here.

Output should not be committed to the code repository. This directory is included in the .gitignore file to
prevent accidental commits.
3 changes: 3 additions & 0 deletions spectroscopy/spectra_generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ labels.append("JADESGS-z7-01-QU")
coords.append(SkyCoord("{} {}".format("+53.15398", "-27.80095"), unit=(u.deg, u.deg)))
labels.append("TestJWST")
coords.append(SkyCoord("{} {}".format("+150.33622", "+55.89878"), unit=(u.deg, u.deg)))
labels.append("Twin Quasar")
sample_table = clean_sample(coords, labels, precision=2.0 * u.arcsecond, verbose=1)
```

Expand Down

0 comments on commit 260dbfc

Please sign in to comment.