Skip to content

Commit

Permalink
Merge pull request #2 from pbeaucage/pr/100
Browse files Browse the repository at this point in the history
Modify GIWAXS to PGGeneralIntegrator and restructure to use integrator machinery
  • Loading branch information
andrewjlevin authored Apr 15, 2024
2 parents d2bfb2a + 312d7d3 commit 782b139
Show file tree
Hide file tree
Showing 4 changed files with 289 additions and 488 deletions.
19 changes: 18 additions & 1 deletion src/PyHyperScattering/FileIO.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,24 @@ def __init__(self,xr_obj):
def savePickle(self,filename):
with open(filename, 'wb') as file:
pickle.dump(self._obj, file)



# - This was copied from the Toney group contribution for GIWAXS.
def saveZarr(self, filename: Union[str, pathlib.Path], mode: str = 'w'):
"""
Save the DataArray as a .zarr file in a specific path, with a file name constructed from a prefix and suffix.
Parameters:
da (xr.DataArray): The DataArray to be saved.
base_path (Union[str, pathlib.Path]): The base path to save the .zarr file.
prefix (str): The prefix to use for the file name.
suffix (str): The suffix to use for the file name.
mode (str): The mode to use when saving the file. Default is 'w'.
"""
ds = da.to_dataset(name='DA')
file_path = pathlib.Path(filename)
ds.to_zarr(file_path, mode=mode)

def saveNexus(self,fileName,compression=5):
data = self._obj
timestamp = datetime.datetime.now()
Expand Down
Loading

0 comments on commit 782b139

Please sign in to comment.