Skip to content

Commit

Permalink
Merge pull request #49 from LSSTDESC/u/jchiang/more_instcat_fixes
Browse files Browse the repository at this point in the history
U/jchiang/more instcat fixes
  • Loading branch information
jchiang87 authored Nov 29, 2017
2 parents 03c7e06 + 9bf1273 commit fb6aeb0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
17 changes: 10 additions & 7 deletions scripts/protoDC2/generateDc2InstCat.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MaskedPhoSimCatalogPoint(PhoSimCatalogPoint):
min_mag = None

column_outputs = ['prefix', 'uniqueId', 'raPhoSim', 'decPhoSim', 'maskedMagNorm', 'sedFilepath',
'redshift', 'shear1', 'shear2', 'kappa', 'raOffset', 'decOffset',
'redshift', 'gamma1', 'gamma2', 'kappa', 'raOffset', 'decOffset',
'spatialmodel', 'internalExtinctionModel',
'galacticExtinctionModel', 'galacticAv', 'galacticRv']

Expand All @@ -43,8 +43,8 @@ def get_inProtoDc2(self):

def column_by_name(self, colname):
if (self.disable_proper_motion and
(colname.startswith('properMotion')
or colname == 'radialVelocity')):
colname in ('properMotionRa', 'properMotionDec',
'radialVelocity', 'parallax')):
return np.zeros(len(self.column_by_name('raJ2000')), dtype=np.float)
return super(MaskedPhoSimCatalogPoint, self).column_by_name(colname)

Expand Down Expand Up @@ -81,9 +81,11 @@ def get_isBright(self):
help='the minimum magintude for stars')
parser.add_argument('--fov', type=float, default=2.0,
help='field of view radius in degrees')
parser.add_argument('--disable_proper_motion', default=False,
parser.add_argument('--enable_proper_motion', default=False,
action='store_true',
help='flag to disable proper motion')
help='flag to enable proper motion')
parser.add_argument('--minsource', type=int, default=100,
help='mininum number of objects in a trimmed instance catalog')
args = parser.parse_args()

obshistid_list = args.id
Expand Down Expand Up @@ -138,6 +140,7 @@ def get_isBright(self):
cat.phoSimHeaderMap = phosim_header_map
with open(cat_name, 'w') as output:
cat.write_header(output)
output.write('minsource %i\n' % args.minsource)
output.write('includeobj %s.gz\n' % star_name)
output.write('includeobj %s.gz\n' % gal_name)
#output.write('includeobj %s.gz\n' % agn_name)
Expand All @@ -147,7 +150,7 @@ def get_isBright(self):
star_cat.phoSimHeaderMap = phosim_header_map
bright_cat = BrightStarCatalog(star_db, obs_metadata=obs, cannot_be_null=['isBright'])
star_cat.min_mag = args.min_mag
star_cat.disable_proper_motion = args.disable_proper_motion
star_cat.disable_proper_motion = not args.enable_proper_motion
bright_cat.min_mag = args.min_mag

from lsst.sims.catalogs.definitions import parallelCatalogWriter
Expand All @@ -168,7 +171,7 @@ def get_isBright(self):

for orig_name in (star_name, gal_name):
full_name = os.path.join(out_dir, orig_name)
with open(full_name, 'r') as input_file:
with open(full_name, 'rb') as input_file:
with gzip.open(full_name+'.gz', 'wb') as output_file:
output_file.writelines(input_file)
os.unlink(full_name)
9 changes: 5 additions & 4 deletions scripts/protoDC2/protoDC2_valid_obsids.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@
import numpy as np
import pandas as pd
from lsst.sims.catUtils.utils import ObservationMetaDataGenerator
from lsst.sims.utils import angularSeparation

def fov_overlaps_protoDC2(x, y, half_size=2.5, radius=1.77):
if x > half_size and y > half_size:
return (x - half_size)**2 + (y - half_size)**2 < radius**2
return angularSeparation(x, y, half_size, half_size) < radius
elif x < -half_size and y > half_size:
return (x + half_size)**2 + (y - half_size)**2 < radius**2
return angularSeparation(x, y, -half_size, half_size) < radius
elif x < -half_size and y < -half_size:
return (x + half_size)**2 + (y + half_size)**2 < radius**2
return angularSeparation(x, y, -half_size, -half_size) < radius
elif x > half_size and y < -half_size:
return (x - half_size)**2 + (y + half_size)**2 < radius**2
return angularSeparation(x, y, half_size, -half_size) < radius
outer_box_size = half_size + radius
return (-outer_box_size < x and x < outer_box_size and
-outer_box_size < y and y < outer_box_size)
Expand Down
Binary file modified scripts/protoDC2/protoDC2_visits.pkl
Binary file not shown.
2 changes: 2 additions & 0 deletions scripts/protoDC2/protoDC2_visits_i-band.txt
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,7 @@
2162113 62766.144126
2166862 62773.106638
2166863 62773.107086
2166865 62773.107982
2166894 62773.121169
2166899 62773.123574
2166900 62773.124024
Expand Down Expand Up @@ -1324,6 +1325,7 @@
925559 60939.097217
925560 60939.097663
925563 60939.099003
925594 60939.114832
925597 60939.116172
926425 60940.072799
926426 60940.073247
Expand Down

0 comments on commit fb6aeb0

Please sign in to comment.