Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

U/jrbogart/fix ci #93

Closed
wants to merge 7 commits into from
Closed
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ jobs:
shell: bash -l {0}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup conda
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: stack
python-version: ${{ matrix.py }}
Expand Down
2 changes: 1 addition & 1 deletion etc/conda_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
stackvana>=0.2023.32
gitpython
dust_extinction
sncosmo
# sncosmo
90 changes: 47 additions & 43 deletions skycatalogs/catalog_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ def __init__(self, parts, area_partition=None, skycatalog_root=None,
_cosmo_cat = 'cosmodc2_v1.1.4_image_addon_knots'
_diffsky_cat = 'roman_rubin_2023_v1.1.2_elais'
_star_db = '/global/cfs/cdirs/lsst/groups/SSim/DC2/dc2_stellar_healpixel.db'
_sn_db = '/global/cfs/cdirs/lsst/groups/SSim/DC2/cosmoDC2_v1.1.4/sne_cosmoDC2_v1.1.4_MS_DDF_healpix.db'
# _sn_db = '/global/cfs/cdirs/lsst/groups/SSim/DC2/cosmoDC2_v1.1.4/sne_cosmoDC2_v1.1.4_MS_DDF_healpix.db'
_sn_db = None


_star_parquet = '/global/cfs/cdirs/descssim/postDC2/UW_star_catalog'

Expand All @@ -284,8 +286,8 @@ def __init__(self, parts, area_partition=None, skycatalog_root=None,
self._galaxy_truth = _diffsky_cat

self._sn_truth = sn_truth
if self._sn_truth is None:
self._sn_truth = _sn_db
# if self._sn_truth is None:
# self._sn_truth = _sn_db

self._sn_object_type = sn_object_type

Expand Down Expand Up @@ -856,7 +858,8 @@ def create_pointsource_catalog(self):
self._logger.debug(f'Point sources. Starting on pixel {p}')
self.create_pointsource_pixel(p, arrow_schema,
star_cat=self._star_truth,
sn_cat=self._sn_truth)
sn_cat=None)
# sn_cat=self._sn_truth)
self._logger.debug(f'Completed pixel {p}')

def create_pointsource_pixel(self, pixel, arrow_schema, star_cat=None,
Expand Down Expand Up @@ -911,43 +914,44 @@ def create_pointsource_pixel(self, pixel, arrow_schema, star_cat=None,
writer.write_table(out_table)

if sn_cat:
# Get data for this pixel
cols = ','.join(['snid_in as id', 'snra_in as ra',
'sndec_in as dec', 'galaxy_id as host_galaxy_id'])

params = ','.join(['z_in as z', 't0_in as t0, x0_in as x0',
'x1_in as x1', 'c_in as c'])

q1 = f'select {cols} from sne_params where hpid={pixel} '
q2 = f'select {params} from sne_params where hpid={pixel} '
with sqlite3.connect(sn_cat) as conn:
sn_df = pd.read_sql_query(q1, conn)
params_df = pd.read_sql_query(q2, conn)

nobj = len(sn_df['ra'])
if nobj > 0:
sn_df['object_type'] = np.full((nobj,), self._sn_object_type)

sn_df['MW_rv'] = make_MW_extinction_rv(sn_df['ra'],
sn_df['dec'])
sn_df['MW_av'] = make_MW_extinction_av(sn_df['ra'],
sn_df['dec'])

# Add fillers for columns not relevant for sn
sn_df['sed_filepath'] = np.full((nobj), '')
sn_df['magnorm'] = np.full((nobj,), None)
sn_df['mura'] = np.full((nobj,), None)
sn_df['mudec'] = np.full((nobj,), None)
sn_df['radial_velocity'] = np.full((nobj,), None)
sn_df['parallax'] = np.full((nobj,), None)
sn_df['variability_model'] = np.full((nobj,), 'salt2_extended')

# Form array of struct from params_df
sn_df['salt2_params'] = params_df.to_records(index=False)
out_table = pa.Table.from_pandas(sn_df, schema=arrow_schema)
self._logger.debug('Created arrow table from sn dataframe')

writer.write_table(out_table)
sn_cat = None
# # Get data for this pixel
# cols = ','.join(['snid_in as id', 'snra_in as ra',
# 'sndec_in as dec', 'galaxy_id as host_galaxy_id'])

# params = ','.join(['z_in as z', 't0_in as t0, x0_in as x0',
# 'x1_in as x1', 'c_in as c'])

# q1 = f'select {cols} from sne_params where hpid={pixel} '
# q2 = f'select {params} from sne_params where hpid={pixel} '
# with sqlite3.connect(sn_cat) as conn:
# sn_df = pd.read_sql_query(q1, conn)
# params_df = pd.read_sql_query(q2, conn)

# nobj = len(sn_df['ra'])
# if nobj > 0:
# sn_df['object_type'] = np.full((nobj,), self._sn_object_type)

# sn_df['MW_rv'] = make_MW_extinction_rv(sn_df['ra'],
# sn_df['dec'])
# sn_df['MW_av'] = make_MW_extinction_av(sn_df['ra'],
# sn_df['dec'])

# # Add fillers for columns not relevant for sn
# sn_df['sed_filepath'] = np.full((nobj), '')
# sn_df['magnorm'] = np.full((nobj,), None)
# sn_df['mura'] = np.full((nobj,), None)
# sn_df['mudec'] = np.full((nobj,), None)
# sn_df['radial_velocity'] = np.full((nobj,), None)
# sn_df['parallax'] = np.full((nobj,), None)
# sn_df['variability_model'] = np.full((nobj,), 'salt2_extended')

# # Form array of struct from params_df
# sn_df['salt2_params'] = params_df.to_records(index=False)
# out_table = pa.Table.from_pandas(sn_df, schema=arrow_schema)
# self._logger.debug('Created arrow table from sn dataframe')

# writer.write_table(out_table)

writer.close()
if self._provenance == 'yaml':
Expand Down Expand Up @@ -1094,8 +1098,8 @@ def write_config(self, overwrite=False, path_only=False):
config.add_key('knots_magnitude_cut', self._knots_mag_cut)

inputs = {'galaxy_truth': self._galaxy_truth}
if self._sn_truth:
inputs['sn_truth'] = self._sn_truth
# if self._sn_truth:
# inputs['sn_truth'] = self._sn_truth
if self._star_truth:
inputs['star_truth'] = self._star_truth
if self._sso_truth:
Expand Down
58 changes: 0 additions & 58 deletions skycatalogs/objects/sncosmo_object.py

This file was deleted.

34 changes: 19 additions & 15 deletions skycatalogs/skyCatalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from skycatalogs.utils.sed_tools import MilkyWayExtinction
from skycatalogs.utils.config_utils import Config
from skycatalogs.utils.shapes import Box, Disk, PolygonalRegion
from skycatalogs.objects.sncosmo_object import SncosmoObject, SncosmoCollection
### from skycatalogs.objects.sncosmo_object import SncosmoObject, SncosmoCollection
from skycatalogs.objects.star_object import StarObject
from skycatalogs.objects.galaxy_object import GalaxyObject
from skycatalogs.objects.diffsky_object import DiffskyObject
Expand Down Expand Up @@ -387,11 +387,11 @@ def __init__(self, config, mp=False, skycatalog_root=None, verbose=False,
object_class=GaiaObject,
collection_class=GaiaCollection,
custom_load=True)
if 'sncosmo' in config['object_types']:
self.cat_cxt.register_source_type(
'sncosmo',
object_class=SncosmoObject,
collection_class=SncosmoCollection)
# if 'sncosmo' in config['object_types']:
# self.cat_cxt.register_source_type(
# 'sncosmo',
# object_class=SncosmoObject,
# collection_class=SncosmoCollection)
if 'star' in config['object_types']:
self.cat_cxt.register_source_type('star',
object_class=StarObject)
Expand Down Expand Up @@ -700,7 +700,8 @@ def get_object_type_by_hp(self, hp, object_type, region=None, mjd=None,
elif object_type in ['snana']:
columns = ['id', 'ra', 'dec', 'start_mjd', 'end_mjd']
id_name = 'id'
elif object_type in ['star', 'sncosmo']:
# elif object_type in ['star', 'sncosmo']:
elif object_type in ['star']:
columns = ['object_type', 'id', 'ra', 'dec']
id_name = 'id'
elif object_type in ['sso']:
Expand Down Expand Up @@ -907,15 +908,18 @@ def open_catalog(config_file, mp=False, skycatalog_root=None, verbose=False):

at_slac = os.getenv('HOME').startswith('/sdf/home/')
if not at_slac:
obj_types = {'star', 'galaxy', 'sncosmo', 'snana'}
# obj_types = {'star', 'galaxy', 'sncosmo', 'snana'}
obj_types = {'star', 'galaxy', 'snana'}
else:
obj_types = {'star', 'galaxy', 'sncosmo', 'snana', 'gaia_star'}
# obj_types = {'star', 'galaxy', 'sncosmo', 'snana', 'gaia_star'}
obj_types = {'star', 'galaxy', 'snana', 'gaia_star'}

print('Invoke get_objects_by_region with box region, no gaia')
t0 = time.time()
object_list = cat.get_objects_by_region(rgn,
obj_type_set={'star', 'galaxy',
'sncosmo'},
obj_type_set={'star', 'galaxy'},
# obj_type_set={'star', 'galaxy',
# 'sncosmo'},
mjd=63200.0)
t_done = time.time()
print('Took ', t_done - t0)
Expand Down Expand Up @@ -1000,10 +1004,10 @@ def open_catalog(config_file, mp=False, skycatalog_root=None, verbose=False):
print('For star magnorm: ', magnorm)
if magnorm < 1000:
print('Length of sed: ', len(sed.wave_list))
elif o.object_type == 'sncosmo':
print(o.get_instcat_entry())
for b in {'u', 'g', 'r', 'i', 'z', 'y'}:
print(o.get_LSST_flux(b))
# elif o.object_type == 'sncosmo':
# print(o.get_instcat_entry())
# for b in {'u', 'g', 'r', 'i', 'z', 'y'}:
# print(o.get_LSST_flux(b))
elif o.object_type == 'galaxy':
for cmp in ['disk', 'bulge', 'knots']:
print(cmp)
Expand Down
2 changes: 1 addition & 1 deletion skycatalogs/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
from .exceptions import *
from .parquet_schema_utils import *
from .sed_tools import *
from .sn_tools import *
# from .sn_tools import *
from .shapes import *
from .creator_utils import *
6 changes: 3 additions & 3 deletions skycatalogs/utils/config_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def assemble_provenance(pkg_root, inputs={}, schema_version=None):
# In config just keep track of models by object type. Information
# about the parameters they require is internal to the code.
_AGN_MODELS = ['agn_random_walk']
_SNCOSMO_MODELS = ['sn_salt2_extended']
# _SNCOSMO_MODELS = ['sn_salt2_extended']


def assemble_variability_models(object_types):
Expand All @@ -305,7 +305,7 @@ def assemble_variability_models(object_types):
models = dict()
if 'agn' in object_types:
models['agn'] = _AGN_MODELS
if 'sncosmo' in object_types:
models['sncosmo'] = _SNCOSMO_MODELS
# if 'sncosmo' in object_types:
# models['sncosmo'] = _SNCOSMO_MODELS

return models
43 changes: 0 additions & 43 deletions skycatalogs/utils/sn_tools.py

This file was deleted.

Loading