This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 = ( |
This file contains hidden or 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
| # /uufs/chpc.utah.edu/common/home/sdss43/dr17/apogee/spectro/redux/dr17/exposures/apogee-n/57282 | |
| # or | |
| # https://dr17.sdss.org/sas/dr17/apogee/spectro/redux/dr17/exposures/apogee-n/57282/ | |
| from glob import glob | |
| from astropy.io import fits | |
| # Just use the middle chip for now | |
| paths = glob("ap2D-b-*.fits") |
This file contains hidden or 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
| # TODO: Library.get(X) should resolve to Library.get(id=X) | |
| # Make & (Document.date > (datetime.now() - timedelta(days=365.25 * 5)) work | |
| # Make document.year > 2017 work | |
| # Make Document.in_(library) and Library.contains(document) work using docs() function | |
| # Remove default behaviour of .limit(10) | |
| # Document.full() should be searchable, and Document.full == '' SHOULD NOT WORK | |
| """ | |
| Give me: | |
| - highly cited people; |
This file contains hidden or 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 pendulum | |
| from datetime import datetime | |
| from airflow import DAG | |
| from airflow.models import DagRun | |
| from airflow.sensors.external_task import ExternalTaskSensor | |
| from airflow.operators.dummy import DummyOperator | |
| def get_most_recent_dag_run(dag_id): | |
| dag_runs = DagRun.find(dag_id=dag_id) |
This file contains hidden or 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 astroquery.gaia import Gaia | |
| import matplotlib.pyplot as plt | |
| import astropy.coordinates as coord | |
| import gala.dynamics as gd | |
| import gala.potential as gp | |
| from astropy import units as u | |
| np.random.seed(42) |
This file contains hidden or 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 | |
| import matplotlib.pyplot as plt | |
| import pystan as stan | |
| model = stan.StanModel(model_code=""" | |
| data { | |
| real parallax; | |
| real parallax_error; | |
| } |
This file contains hidden or 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 astroquery.gaia import Gaia | |
| import matplotlib.pyplot as plt | |
| def astrometry_covariance_matrix(source): | |
| """ | |
| Construct a covariance matrix for a 5-parameter astrometric solution | |
| measured by Gaia for a single source. |