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

Ellipticity, position angle correction in protodc2 GCR. #48

Merged
merged 26 commits into from
Dec 8, 2017
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4e488d0
Added sky area to the reader. Added a minor-minor version number. Mov…
dkorytov Dec 5, 2017
e054148
added ellipciticy to the exposed quantities
dkorytov Dec 5, 2017
a5bebf6
Changed version checking to use StrictVersion
dkorytov Dec 5, 2017
b38244c
add commas to end of dictionary creation/moditications
dkorytov Dec 5, 2017
868dee0
updated the yaml files for the newer catalog version.
dkorytov Dec 5, 2017
47839a5
changed quantity modifiers to be the lastest by default. Older catalo…
dkorytov Dec 5, 2017
6456a18
Copied over Yao's method of getting the catlaog version
dkorytov Dec 5, 2017
334accf
Corrected to use strictVersion for catalog version
dkorytov Dec 5, 2017
c119c41
removed unneeded parenthesis
dkorytov Dec 5, 2017
4bbdfa3
get info quantities added
dkorytov Dec 5, 2017
7fde16e
removed stray print
dkorytov Dec 5, 2017
2ea4cd3
string casting for info dict. Commas and spaces
dkorytov Dec 5, 2017
e5df64e
Decode instead of casting to a string
dkorytov Dec 5, 2017
a2a5763
added None given -> None conversion
dkorytov Dec 5, 2017
71cdfea
copied Yao's condensed implementation for get info quanties funcitons
dkorytov Dec 5, 2017
d18b2c1
imported warning
dkorytov Dec 5, 2017
b398cae
import warnginSSSS <- missed the s
dkorytov Dec 5, 2017
b6c41fc
added corrections to ellipticity_1 and position angle
dkorytov Dec 7, 2017
ac3862f
Added corrections to ellip1, position_angle. Included size_true
dkorytov Dec 7, 2017
2ef50df
merged with upstream
dkorytov Dec 7, 2017
19e92d5
Fixed commas. Used an explicit deg2rad function. Added comments. Remo…
dkorytov Dec 8, 2017
7481f56
updated version number
dkorytov Dec 8, 2017
0e7ce3c
re-added the sky area
dkorytov Dec 8, 2017
fdddb14
Ensured sky_area is a float
dkorytov Dec 8, 2017
d8f30b5
default sky area is a float
dkorytov Dec 8, 2017
9e8ea45
used rad2deg function. Modified comments for clearity.
dkorytov Dec 8, 2017
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
17 changes: 13 additions & 4 deletions GCRCatalogs/alphaq.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from GCR import BaseGenericCatalog
from distutils.version import StrictVersion
__all__ = ['AlphaQGalaxyCatalog']
__version__ = '2.1.1.1' #version 1 for the 2.1.1 catalog reader


Copy link
Member

Choose a reason for hiding this comment

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

Add a line __version__ = '2.1.1.1' (or your preferred versioning scheme) to indicate the version of this reader file.

class AlphaQGalaxyCatalog(BaseGenericCatalog):
Expand All @@ -23,7 +24,7 @@ def _subclass_init(self, filename, **kwargs):
assert os.path.isfile(filename), 'Catalog file {} does not exist'.format(filename)
self._file = filename
self.lightcone = kwargs.get('lightcone')


with h5py.File(self._file, 'r') as fh:
self.cosmology = FlatLambdaCDM(
Expand All @@ -38,8 +39,12 @@ def _subclass_init(self, filename, **kwargs):
catalog_version.append(fh['/metaData/version' + version_label].value)
except KeyError:
break

catalog_version = StrictVersion('.'.join(map(str, catalog_version or (2, 0))))
catalog_version = StrictVersion('.'.join(map(str, catalog_version or (2, 0))))
if catalog_version >= StrictVersion("2.1.1"):
self.sky_area = fh['metaData/skyArea'].value
else:
self.sky_area = 25 #If the sky area isn't specified use the default value of the sky area.

Copy link
Member

Choose a reason for hiding this comment

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

add self.sky_area = float(self.sky_area) to ensure it is a float

config_version = StrictVersion(kwargs.get('version', '0.0'))
if config_version != catalog_version:
raise ValueError('Catalog file version {} does not match config version {}'.format(catalog_version, config_version))
Expand All @@ -65,7 +70,9 @@ def _subclass_init(self, filename, **kwargs):
'size_bulge_true': 'morphology/spheroidHalfLightRadius',
'disk_sersic_index': 'morphology/diskSersicIndex',
'bulge_sersic_index': 'morphology/spheroidSersicIndex',
'ellipticity_1': 'morphology/totalEllipticity1',
'position_angle': (lambda pos_angle: np.rad2deg(np.rad2deg(pos_angle)), 'morphology/positionAngle'), #I converted the units the wrong way, so a double conversion is required.
'ellipticity_1': (lambda ellip2, pos_angle: ellip2/np.tan(2*pos_angle*(180.0/np.pi)), 'morphology/totalEllipticity2', 'morphology/positionAngle'), #By accident used a sin instead of cos when computing the value
'size_true': (lambda size1, size2, lum1, lum2: ((size1*lum1)+(size2*lum2))/(lum1+lum2), 'morphology/diskHalfLightRadius', 'morphology/spheroidHalfLightRadius', 'LSST_filters/diskLuminositiesStellar:LSST_r:rest', 'LSST_filters/spheroidLuminositiesStellar:LSST_r:rest'),
'ellipticity_2': 'morphology/totalEllipticity2',
'position_x': 'x',
'position_y': 'y',
Expand Down Expand Up @@ -129,6 +136,7 @@ def native_quantity_getter(native_quantity):
yield native_quantity_getter



def _get_native_quantity_info_dict(self, quantity, default=None):
with h5py.File(self._file, 'r') as fh:
quantity_key = 'galaxyProperties/' + quantity
Expand All @@ -137,6 +145,7 @@ def _get_native_quantity_info_dict(self, quantity, default=None):
modifier = lambda k, v: None if k=='description' and v==b'None given' else v.decode()
return {k: modifier(k, v) for k, v in fh[quantity_key].attrs.items()}



def _get_quantity_info_dict(self, quantity, default=None):
q_mod = self.get_quantity_modifier(quantity)
Expand Down
2 changes: 1 addition & 1 deletion GCRCatalogs/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.6.8'
__version__ = '0.6.9'