GitHub PullRequestReviewCommentEvent at 2014-04-08 15:40:54
Repository: pisa
Actor: sboeser
Payload: {"comment":{"url":"https://api.github.com/repos/sboeser/pisa/pulls/comments/11395741","id":11395741,"diff_hunk":"@@ -0,0 +1,123 @@\n+#! /usr/bin/env python\n+#\n+# EventCountsOscMC.py\n+#\n+# This module is the implementation of the stage2 analysis using the\n+# full Monte Carlo simulations. The main purpose of stage2 is to\n+# combine the atmospheric flux model with the oscillation probability \n+# map to create the \"oscillated Flux maps\", which becomes the input of\n+# stage2-the reconstruction step.\n+# \n+# If desired, this will create a .json output file with the results of\n+# the current stage of processing.\n+#\n+# author: Timothy C. Arlen\n+#\n+#         tca3@psu.edu\n+#\n+# date:   Jan. 21, 2014\n+#\n+\n+import os,sys\n+import numpy as np\n+import logging\n+from argparse import ArgumentParser, RawTextHelpFormatter\n+from utils.utils import set_verbosity,is_equal_binning\n+from utils.json import from_json, to_json\n+\n+\n+def get_osc_counts(osc_flux_maps,sim_file=None,livetime=None,nu_xsec_scale=None,\n+                   nu_bar_xsec_scale=None,**kwargs):\n+    '''\n+    Main function for this module, which returns the counts maps for\n+    each flavor and interaction type, using true energy and zenith\n+    information. The content of each bin will be the simulated weight\n+    multiplied by the oscillation probability, so that \n+\n+    Returned dictionary will be of the form:\n+        {'nue':{'cc':map,'nc':map}, \n+         'nue_bar':{'cc':map,'nc':map}, ...\n+         'nutau_bar':{'cc':map,'nc':map} \n+         }\n+    '''\n+\n+    # Verify consistent binning.\n+    ebins = osc_flux_maps['nue']['ebins']\n+    czbins = osc_flux_maps['nue']['czbins']\n+    flavours = ['nue','numu','nutau','nue_bar','numu_bar','nutau_bar']\n+    if not np.alltrue([is_equal_binning(ebins,osc_flux_maps[nu]['ebins']) for nu in flavours]):\n+        raise Exception('Osc flux maps have different energy binning!')\n+    if not np.alltrue([is_equal_binning(czbins,osc_flux_maps[nu]['czbins']) for nu in flavours]):\n+        raise Exception('Osc flux maps have different coszen binning!')\n+\n+    osc_counts_maps = {}\n+    \n+    \n+    return osc_counts_maps\n+\n+\n+if __name__ == '__main__':\n+\n+    #Only show errors while parsing \n+    set_verbosity(0)\n+    parser = ArgumentParser(description='Take an oscillated flux file '\n+                            'as input and write out a set of oscillated event counts. ',\n+                            formatter_class=RawTextHelpFormatter)\n+    parser.add_argument('osc_flux_file',metavar='FLUX',type=from_json,\n+                        help='''JSON osc flux input file with the following parameters:\n+      {\"nue\": {'czbins':[], 'ebins':[], 'map':[]}, \n+       \"numu\": {...},\n+       \"nutau\": {...},\n+       \"nue_bar\": {...},\n+       \"numu_bar\": {...},\n+       \"nutau_bar\": {...} }''')\n+    parser.add_argument('simfile',type=str,help='''HDF5 File containing data from all flavours for a particular instumental geometry. Expects the file format to be:\n+      {\n+        'nue': {\n+           'cc': {\n+               'sim_weight': np.array,\n+               'true_energy': np.array,\n+               'true_coszen': np.array,\n+               'reco_energy': np.array,\n+               'reco_coszen': np.array\n+            },\n+            'nc': {...\n+             }\n+         },\n+         'nue_bar' {...},...\n+      } ''')\n+    parser.add_argument('--livetime',type=float,default=1.0,\n+                        help='''livetime in years to re-scale by.''')\n+    parser.add_argument('--nu_xsec',type=float,default=1.0,","path":"event_counts/EventCountsOsc.py","position":91,"original_position":91,"commit_id":"8aab03eef73c9e7643c278257fae836fbc93cc20","original_commit_id":"8aab03eef73c9e7643c278257fae836fbc93cc20","user":{"login":"sboeser","id":2905745,"avatar_url":"https://avatars.githubusercontent.com/u/2905745?","gravatar_id":"096d39b16db55d7a642fb8cf6145321a","url":"https://api.github.com/users/sboeser","html_url":"https://github.com/sboeser","followers_url":"https://api.github.com/users/sboeser/followers","following_url":"https://api.github.com/users/sboeser/following{/other_user}","gists_url":"https://api.github.com/users/sboeser/gists{/gist_id}","starred_url":"https://api.github.com/users/sboeser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sboeser/subscriptions","organizations_url":"https://api.github.com/users/sboeser/orgs","repos_url":"https://api.github.com/users/sboeser/repos","events_url":"https://api.github.com/users/sboeser/events{/privacy}","received_events_url":"https://api.github.com/users/sboeser/received_events","type":"User","site_admin":false},"body":"Since this is not the x-section, but just its uncertainty, I'd rather call it `nu_xsec_scale`. Also the description is quite misleading, since it is not the __uncertainty__ that we provide, but a __scale factor__.","created_at":"2014-04-08T15:40:54Z","updated_at":"2014-04-08T15:40:54Z","html_url":"https://github.com/sboeser/pisa/pull/5#discussion_r11395741","pull_request_url":"https://api.github.com/repos/sboeser/pisa/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/sboeser/pisa/pulls/comments/11395741"},"html":{"href":"https://github.com/sboeser/pisa/pull/5#discussion_r11395741"},"pull_request":{"href":"https://api.github.com/repos/sboeser/pisa/pulls/5"}}}}