Skip to content
Merged
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 requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ numpy==1.26.4
pandas==2.0.3
pytest==8.3.4
requests==2.32.4
specutils==2.0.0
specutils==2.2.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

JWST spectra was still not working with 2.0.0, but 2.2.0 works well

SQLAlchemy==2.0.38
tqdm==4.67.1
Werkzeug==3.1.4
Expand Down
9 changes: 7 additions & 2 deletions simple_app/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def normalise() -> np.ndarray:
db = SimpleDB(db_file) # open database
t_spectra: Table = db.query(db.Spectra).\
filter(db.Spectra.c.source == query).\
table(spectra=['access_url'])
table() # do not use spectra=['access_url'] here, it will try to read the spectra as Spectrum objects
Copy link
Collaborator

Choose a reason for hiding this comment

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

This was missing and is required to prevent astrodbkit from auto-converting the spectra, that is done manually now in line 178


# initialise plot
n_fail, fail_string_list = 0, []
Expand All @@ -173,7 +173,12 @@ def normalise() -> np.ndarray:

# checking each spectra in table
for spec in t_spectra:
spectrum: Spectrum1D = spec['access_url']
try:
# Manually convert the spectrum to a Spectrum object
spectrum = Spectrum.read(spec['access_url'], cache=True)
except Exception as e:
print(f"Unable to read {spec['access_url']} as Spectrum. Error: {e}")
continue

# checking spectrum has good units and not only NaNs or 0s
try:
Expand Down
82 changes: 52 additions & 30 deletions simple_app/simports.py
Copy link
Collaborator

Choose a reason for hiding this comment

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

Changes here were Ruff import sorting. I did explicitly add from specutils import Spectrum

Original file line number Diff line number Diff line change
@@ -1,47 +1,69 @@
"""
Importing all packages
"""
# external packages

import argparse # parsing the arguments given with file
import os # operating system
import sys # system arguments
from copy import deepcopy # memory control
from difflib import get_close_matches # for redirecting bad file paths
from io import BufferedIOBase, BytesIO, StringIO # writing files without saving to disk
from shutil import copy # copying files
from sqlite3 import Warning as SqliteWarning # errors from sqlite
from time import localtime, strftime # time stuff for naming files
from typing import Dict, Generator, List, Optional, Tuple, Union # type hinting (good in IDEs)
from urllib.parse import quote # handling strings into url friendly form
from zipfile import ZipFile # zipping files together

import astropy.units as u # units
import multiprocess as mp # multiprocessing for efficiency
import numpy as np # numerical python
import pandas as pd # running dataframes
import pytest # testing
import requests # accessing internet
from astrodbkit.astrodb import Database # used for pulling out database and querying
from astropy.coordinates import SkyCoord # coordinates
from astropy.io import fits # handling fits files
import astropy.units as u # units
from astropy.table import Table # tables in astropy
from bokeh.embed import components # converting python bokeh to javascript
from bokeh.layouts import row, column # bokeh displaying nicely
from bokeh.models import ColumnDataSource, Range1d, CustomJS, \
Select, Toggle, TapTool, OpenURL, HoverTool, Span, RangeSlider, Label, ColorBar, FixedTicker # bokeh models
from bokeh.layouts import column, row # bokeh displaying nicely
from bokeh.models import (
ColorBar,
ColumnDataSource,
CustomJS,
FixedTicker,
HoverTool,
Label,
OpenURL,
Range1d,
RangeSlider,
Select, # bokeh models
Span,
TapTool,
Toggle,
)
from bokeh.palettes import Colorblind8, Turbo256 # plotting palettes
from bokeh.plotting import figure, curdoc # bokeh plotting
from bokeh.plotting import curdoc, figure # bokeh plotting
from bokeh.resources import CDN # resources for webpage
from bokeh.themes import built_in_themes, Theme # appearance of bokeh glyphs
from bokeh.themes import Theme, built_in_themes # appearance of bokeh glyphs
from bokeh.transform import linear_cmap # making colour maps
from flask import (Flask, render_template, jsonify, send_from_directory, redirect, url_for,
Response, abort, request, session) # website
from flask import (
Flask,
Response, # website
abort,
jsonify,
redirect,
render_template,
request,
send_from_directory,
session,
url_for,
)
from flask_cors import CORS # cross origin fix (aladin mostly)
from flask_wtf import FlaskForm # web forms
from markdown2 import markdown # using markdown formatting
import numpy as np # numerical python
import pandas as pd # running dataframes
import pytest # testing
from specutils import Spectrum1D # spectrum objects
from sqlalchemy.exc import ResourceClosedError, OperationalError, ProgrammingError # errors from sqlalchemy
from sqlite3 import Warning as SqliteWarning # errors from sqlite
from specutils import Spectrum
from sqlalchemy.exc import OperationalError, ProgrammingError, ResourceClosedError # errors from sqlalchemy
from tqdm import tqdm # progress bars
from werkzeug.exceptions import HTTPException # underlying http
from wtforms import StringField, SubmitField, TextAreaField, ValidationError # web forms

# internal packages
import argparse # parsing the arguments given with file
from copy import deepcopy # memory control
from difflib import get_close_matches # for redirecting bad file paths
from io import StringIO, BytesIO, BufferedIOBase # writing files without saving to disk
import multiprocess as mp # multiprocessing for efficiency
import os # operating system
import requests # accessing internet
from shutil import copy # copying files
import sys # system arguments
from time import strftime, localtime # time stuff for naming files
from typing import Tuple, Optional, List, Union, Dict, Generator # type hinting (good in IDEs)
from urllib.parse import quote # handling strings into url friendly form
from zipfile import ZipFile # zipping files together