Skip to content

Commit

Permalink
Fix data IO unit test. All axisting tests are working.
Browse files Browse the repository at this point in the history
  • Loading branch information
israelmcmc committed May 6, 2024
1 parent 8a631cf commit 759b518
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
Binary file not shown.
15 changes: 15 additions & 0 deletions cosipy/test_data/inputs_crab.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#----------#
# Data I/O:

# data files available on the COSI Sharepoint: https://drive.google.com/drive/folders/1UdLfuLp9Fyk4dNussn1wt7WEOsTWrlQ6
data_file: "GalacticScan.inc1.id1.crab2hr.extracted.testsample.tra.gz" # full path
ori_file: "NA" # full path
unbinned_output: 'hdf5' # 'fits' or 'hdf5'
time_bins: 60 # time bin size in seconds. Takes int, float, or list of bin edges.
energy_bins: [100., 200., 500., 1000., 2000., 5000.] # Takes list. Needs to match response.
phi_pix_size: 6 # binning of Compton scattering anlge [deg]
nside: 8 # healpix binning of psi chi local
scheme: 'ring' # healpix binning of psi chi local
tmin: 1835478000.0 # Min time cut in seconds.
tmax: 1835485200.0 # Max time cut in seconds.
#----------#
29 changes: 15 additions & 14 deletions tests/dataIO/test_unbinned_data_with_MEGAlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,21 @@ def compare(original,new,title,make_plots=False):
# Read in MEGAlib's calculations from its event reader:
mega_data = os.path.join(test_data.path,"unbinned_data_MEGAlib_calc.hdf5")
dict_old = analysis.get_dict_from_hdf5(mega_data)
energy_old = dict_old["Energies"]
time_old = dict_old["TimeTags"]
phi_old = dict_old["Phi"]
dist_old = dict_old["Distance"]
lonX_old = dict_old["Xpointings"].T[0]
latX_old = dict_old["Xpointings"].T[1]
lonZ_old = dict_old["Zpointings"].T[0]
latZ_old = dict_old["Zpointings"].T[1]
lonY_old = dict_old["Ypointings"].T[0]
latY_old = dict_old["Ypointings"].T[1]
chi_loc_old = dict_old['Chi local']
psi_loc_old = dict_old['Psi local']
chi_gal_old = dict_old['Chi galactic']
psi_gal_old = dict_old['Psi galactic']
ntestsamples = analysis.cosi_dataset["Energies"].size #Using a reduced dataset for testing purposes
energy_old = dict_old["Energies"][:ntestsamples]
time_old = dict_old["TimeTags"][:ntestsamples]
phi_old = dict_old["Phi"][:ntestsamples]
dist_old = dict_old["Distance"][:ntestsamples]
lonX_old = dict_old["Xpointings"].T[0][:ntestsamples]
latX_old = dict_old["Xpointings"].T[1][:ntestsamples]
lonZ_old = dict_old["Zpointings"].T[0][:ntestsamples]
latZ_old = dict_old["Zpointings"].T[1][:ntestsamples]
lonY_old = dict_old["Ypointings"].T[0][:ntestsamples]
latY_old = dict_old["Ypointings"].T[1][:ntestsamples]
chi_loc_old = dict_old['Chi local'][:ntestsamples]
psi_loc_old = dict_old['Psi local'][:ntestsamples]
chi_gal_old = dict_old['Chi galactic'][:ntestsamples]
psi_gal_old = dict_old['Psi galactic'][:ntestsamples]

# For comparing chi_loc, psi_loc=0 values are arbitrary,
# so we exclude them from the comparison.
Expand Down

0 comments on commit 759b518

Please sign in to comment.