This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from scipy import sparse, stats | |
from typing import Sequence, Optional | |
_fwhm_to_sigma = 1 / (2 * np.sqrt(2 * np.log(2))) | |
def instrument_lsf_kernel( | |
λi: Sequence[float], | |
λo: Sequence[float], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://monash.zoom.us/my/andy.casey?pwd=U3JHOThFYzEzbXVMbWs5eGFmV1F2UT09 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This uses `ads` v1 (nightly). | |
# Running this reveals 533 unique astronomers and their ORCIDs, | |
# but there are more: I limited the query to 1000 ADS entries. | |
from ads import Document | |
from tqdm import tqdm | |
import json | |
docs = ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example to sample from the observed quantities and run each sample through StarFit | |
# In this example we will say that we have the following abundances: | |
# [C/Fe] = -1.1 +/- 0.2 | |
# [N/Fe] = -0.5 +/- 0.1 | |
# [Mg/Fe] < 0.3 | |
# Whenever you're generating random numbers, you should always "seed" the random number generator. | |
# That way you'll still get "random"-esque numbers, but if you run your code twice you will get the same "random" numbers. | |
# If the numbers were really random each time you ran the code then it would be difficult to debug things. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from astropy.io import fits | |
def generate_apogee_hdu(observatory="APO", with_wl=True): | |
wl = (10**(4.179 + 6e-6 * np.arange(8575))).reshape((1, -1)) | |
flux = np.zeros_like(wl) | |
ivar = np.zeros_like(wl) | |
pixel_flags = np.zeros_like(wl) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import numpy as np | |
import pickle | |
import warnings | |
from itertools import cycle | |
from functools import cached_property | |
from scipy import optimize as op | |
from sklearn.linear_model import Lasso, LinearRegression | |
from joblib import Parallel, delayed | |
from time import time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cartons = [ | |
SimplifiedCarton.create(id=5, carton="star"), | |
SimplifiedCarton.create(id=8, carton="galaxy") | |
] | |
source = Source.create(ra=0, dec=0) | |
source.carton_flags.set_bit(5) # add to star | |
source.carton_flags.set_bit(8) # add to galaxy | |
print(source.carton_flags) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This minimum reproducible example demonstrates a way to use bitfield flags to store the cartons | |
that a source is assigned to. | |
What does it do? | |
---------------- | |
1. Creates a `Source` table and inserts 10,000 random sources. | |
2. Creates some `SimplifiedCarton` entries based on unique names currently in targetdb. | |
3. Assigns sources to random cartons (many more than what would exist in reality). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
import numpy as np | |
import warnings | |
from sklearn.decomposition._nmf import non_negative_factorization, _fit_multiplicative_update | |
from sklearn.exceptions import ConvergenceWarning | |
from astropy.nddata import InverseVariance | |
from typing import Optional, Union, Tuple, List | |
from specutils import SpectralAxis, Spectrum1D |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from astropy.table import Table | |
data = Table.read("/uufs/chpc.utah.edu/common/home/sdss50/dr17/apogee/spectro/aspcap/dr17/synspec_rev1/allStar-dr17-synspec_rev1.fits") | |
column_names = data.dtype.names | |
ignore = ["TIII_FE"] | |
available_elements = [ea for ea in column_names if f"{ea}_FLAG" in column_names and ea not in ignore] | |
keep = ( |
NewerOlder