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

Stellar mass function test #51

Merged
merged 2 commits into from
Dec 26, 2017
Merged

Stellar mass function test #51

merged 2 commits into from
Dec 26, 2017

Conversation

evevkovacs
Copy link
Contributor

@evevkovacs evevkovacs commented Dec 21, 2017

The last 2 functions in the test could go into a utilities module as they are more generally useful. Here's the link to the last run before the pull request.
[]https://portal.nersc.gov/project/lsst/descqa/v2/?run=2017-12-20_36&test=SMF_PRIMUS

@aphearin
Copy link

Happy to see get_opt_binpoints make it in the code @evevkovacs. I agree that's useful enough to be peeled out into a utils module.

Copy link
Member

@yymao yymao left a comment

Choose a reason for hiding this comment

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

@evevkovacs thanks. Mostly minor style stuffs (taken from here).

Can you also post a link to the DESCQA web interface of a run for this test?


@staticmethod
def get_sky_volume(catalog_instance, zhi, zlo=0., distance='Mpc'):
from astropy.cosmology import FlatLambdaCDM
Copy link
Member

Choose a reason for hiding this comment

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

Move import statement to the beginning of the module

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

'missingdata':'...'
},
}
zkey_match ='< z <'
Copy link
Member

Choose a reason for hiding this comment

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

one space after =

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

'PRIMUS_2013': {
'filename_template': 'SMF/moustakas_et_al_2013/Table{}.txt',
'file-info': {'0. < z < .1':{'zlo':0., 'zhi':.1, 'table#':3, 'usecols':[0,1,2,3]},
'.2 < z < .3':{'zlo':.2, 'zhi':.3, 'table#':4, 'usecols':[0,1,2,3]},
Copy link
Member

Choose a reason for hiding this comment

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

minor but aligning the first quote symbol in this and following lines would make this look nicer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

msize = 4 #marker-size

def __init__(self, z='redshift_true', mass='stellar_mass', Nbins=25, log_Mlo=8., log_Mhi=12.,
observation='', zlo=0., zhi=1.0, zint =0.2, ncolumns=2, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

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

remove the space right after zint

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


def init_plots(self, zlo, zhi, zint):
#get magnitude cuts based on validation data or default limits (only catalog data plotted)
if len(self.validation_data )> 0:
Copy link
Member

Choose a reason for hiding this comment

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

change to if not self.validation_data:

Copy link
Contributor Author

@evevkovacs evevkovacs Dec 21, 2017

Choose a reason for hiding this comment

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

Done, but flipped the order around so it would work correctly.

def run_on_single_catalog(self, catalog_instance, catalog_name, output_dir):
#update color and marker to preserve catalog colors and markers across tests
catalog_color = next(self._color_iterator)
catalog_marker= next(self.markers)
Copy link
Member

Choose a reason for hiding this comment

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

catalog_marker is not used

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.



@staticmethod
def get_sky_volume(catalog_instance, zhi, zlo=0., distance='Mpc'):
Copy link
Member

Choose a reason for hiding this comment

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

distance is not used in this function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK I changed distance to units and added a check for units=='Mpc'. If this is going to be a function in a utilities module, we could have something more bulletproof than this. Lots of test developers will need a "get_sky_volume" function. It would save everyone doing it for themselves and will help with minimizing errors if we offer it, I think.

@@ -0,0 +1,353 @@
from __future__ import print_function, division, unicode_literals, absolute_import
import os
import math
Copy link
Member

Choose a reason for hiding this comment

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

remove this line because math is not used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


from .base import BaseValidationTest, TestResult
from .plotting import plt
from itertools import cycle
Copy link
Member

Choose a reason for hiding this comment

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

move these two lines (from itertools import cycle and from itertools import count) to before import numpy as np

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

sumM += np.histogram(M_this, bins=self.Mbins, weights=M_this)[0]
sumM2 += np.histogram(M_this, bins=self.Mbins, weights=M_this**2)[0]

if not N.sum():
Copy link
Member

Choose a reason for hiding this comment

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

I understand what this is doing, but I wonder if we should raise an error instead of skip the catalog?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I agree. If the catalog claims to have a quantity but nothing is there (eg dc1) then we should know. Also the test condition was wrong, so I fixed it.

@yymao yymao mentioned this pull request Dec 21, 2017
@evevkovacs
Copy link
Contributor Author

evevkovacs commented Dec 21, 2017

OK, I made all the changes and added a couple of minor improvements. I also checked that the code runs with no observation Latest test run: []https://portal.nersc.gov/project/lsst/descqa/v2/?run=2017-12-21_14 and run without observation is on []https://portal.nersc.gov/project/lsst/descqa/v2/?run=2017-12-21_17

@yymao
Copy link
Member

yymao commented Dec 21, 2017

@evevkovacs thanks, remember to commit your changes to this branch!

@evevkovacs
Copy link
Contributor Author

OK done.

@yymao yymao merged commit f4f38c1 into LSSTDESC:master Dec 26, 2017
@yymao yymao mentioned this pull request Dec 26, 2017
4 tasks
@evevkovacs evevkovacs deleted the smf_test branch June 14, 2018 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants