Skip to content

Commit

Permalink
Merge branch 'wasabi_pathlib' into scatt_map_docs
Browse files Browse the repository at this point in the history
  • Loading branch information
israelmcmc committed Mar 12, 2024
2 parents 552c28d + 17ff708 commit c1f9139
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 42 deletions.
24 changes: 11 additions & 13 deletions cosipy/data_io/ReadTraTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ def read_tra_old(self,make_plots=True):

"""Reads in MEGAlib .tra (or .tra.gz) file.
Extended Summary
----------------
This method uses MEGAlib to read events from the tra file.
This is used to compare to the new event reader, which is
independent of MEGAlib.
Expand All @@ -41,17 +39,17 @@ def read_tra_old(self,make_plots=True):
-------
cosi_dataset : dict
Returns COSI dataset as a dictionary of the form:
cosi_dataset = {'Full filename':self.data_file,
'Energies':erg,
'TimeTags':tt,
'Xpointings':np.array([lonX,latX]).T,
'Ypointings':np.array([lonY,latY]).T,
'Zpointings':np.array([lonZ,latZ]).T,
'Phi':phi,
'Chi local':chi_loc,
'Psi local':psi_loc,
'Distance':dist,
'Chi galactic':chi_gal,
cosi_dataset = {'Full filename':self.data_file,\
'Energies':erg,\
'TimeTags':tt,\
'Xpointings':np.array([lonX,latX]).T,\
'Ypointings':np.array([lonY,latY]).T,\
'Zpointings':np.array([lonZ,latZ]).T,\
'Phi':phi,\
'Chi local':chi_loc,\
'Psi local':psi_loc,\
'Distance':dist,\
'Chi galactic':chi_gal,\
'Psi galactic':psi_gal}
Note
Expand Down
40 changes: 19 additions & 21 deletions cosipy/data_io/UnBinnedData.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,27 @@ def read_tra(self, output_name=None, run_test=False, use_ori=False,
cosi_dataset, dict
The returned dictionary contains the COSI dataset, which
has the form:
cosi_dataset = {'Energies':erg,
'TimeTags':tt,
'Xpointings':np.array([lonX,latX]).T,
'Ypointings':np.array([lonY,latY]).T,
'Zpointings':np.array([lonZ,latZ]).T,
'Phi':phi,
'Chi local':chi_loc,
'Psi local':psi_loc,
'Distance':dist,
'Chi galactic':chi_gal,
'Psi galactic':psi_gal}
Arrays contain unbinned photon data.
cosi_dataset = {'Energies':erg,\
'TimeTags':tt,\
'Xpointings':np.array([lonX,latX]).T,\
'Ypointings':np.array([lonY,latY]).T,\
'Zpointings':np.array([lonZ,latZ]).T,\
'Phi':phi,\
'Chi local':chi_loc,\
'Psi local':psi_loc,\
'Distance':dist,\
'Chi galactic':chi_gal,\
'Psi galactic':psi_gal}\
Arrays contain unbinned photon data.
Notes
-----
The current code is only able to handle data with Compton
events. It will need to be modified to handle single-site
and pair events.
The current code is only able to handle data with Compton
events. It will need to be modified to handle single-site
and pair events.
This method sets the instance attribute, cosi_dataset,
but it does not explicitly return this.
This method sets the instance attribute, cosi_dataset,
but it does not explicitly return this.
"""

start_time = time.time()
Expand Down Expand Up @@ -376,8 +376,6 @@ def instrument_pointing(self):

"""Get pointing information from ori file.
Extended Summary
---------------
Initializes interpolated functions for lonx, latx, lonz, latz
in radians.
Expand Down Expand Up @@ -555,8 +553,8 @@ def get_dict_from_hdf5(self, input_hdf5):

"""Constructs dictionary from input hdf5 file
Parameter
---------
Parameters
----------
input_hdf5 : str
Name of input hdf5 file.
Expand Down
2 changes: 1 addition & 1 deletion cosipy/spacecraftfile/SpacecraftFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ def get_scatt_map(self,
"""
Bin the spacecraft attitude history into a 4D histogram that contains the accumulated time the axes of the spacecraft where looking at a given direction.
Paremeters
Parameters
----------
nside : int
The nside of the scatt map.
Expand Down
18 changes: 11 additions & 7 deletions cosipy/util/data_fetching.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
from awscli.clidriver import create_clidriver
from pathlib import Path

def fetch_wasabi_file(file,
output = None,
Expand Down Expand Up @@ -31,16 +32,19 @@ def fetch_wasabi_file(file,
if output is None:
output = file.split('/')[-1]

if os.path.exists(output) and not override:
output = Path(output)

if output.exists() and not override:
raise RuntimeError(f"File {output} already exists.")

cli = create_clidriver()

cli.session.set_credentials(access_key, secret_key)

cli.main(['s3api', 'get-object',
'--bucket', bucket,
'--key', file,
'--endpoint-url', endpoint,
output])
command = ['s3api', 'get-object',
'--bucket', bucket,
'--key', file,
'--endpoint-url', endpoint,
str(output)]

cli.main(command)

1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
'pandas',
'tqdm',
'scipy',
'psutil',
'awscli']

# There seems to be a conflict between unittest.mock (used by sphinx) and metaclasses
Expand Down

0 comments on commit c1f9139

Please sign in to comment.