fits2tmp 0.1.8__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fits2tmp-0.1.8 → fits2tmp-0.2.0}/PKG-INFO +1 -1
- {fits2tmp-0.1.8 → fits2tmp-0.2.0}/pyproject.toml +1 -1
- fits2tmp-0.2.0/src/fits2tmp/dask-output.log +0 -0
- {fits2tmp-0.1.8 → fits2tmp-0.2.0}/src/fits2tmp/fits2tmp.py +48 -31
- {fits2tmp-0.1.8 → fits2tmp-0.2.0}/LICENSE +0 -0
- {fits2tmp-0.1.8 → fits2tmp-0.2.0}/README.md +0 -0
- {fits2tmp-0.1.8 → fits2tmp-0.2.0}/src/fits2tmp/__init__.py +0 -0
- {fits2tmp-0.1.8 → fits2tmp-0.2.0}/src/fits2tmp/sdc2_100.fits +0 -0
- {fits2tmp-0.1.8 → fits2tmp-0.2.0}/src/fits2tmp/sofiatestrewrite1002_cat.txt +0 -0
- {fits2tmp-0.1.8 → fits2tmp-0.2.0}/src/fits2tmp/sofiatestrewrite1002_cat.xml +0 -0
- {fits2tmp-0.1.8 → fits2tmp-0.2.0}/src/fits2tmp/sofiatestrewrite100_cat.txt +0 -0
- {fits2tmp-0.1.8 → fits2tmp-0.2.0}/src/fits2tmp/sofiatestrewrite100_cat.xml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: fits2tmp
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: A way of loading FITS files into temporary filesystems to make them available in memory.
|
|
5
5
|
Home-page: https://gitlab.developers.cam.ac.uk/phy/ra/vla22-phd/fits2tmp
|
|
6
6
|
License: BSD-3-Clause
|
|
File without changes
|
|
@@ -79,48 +79,65 @@ def fits2tmpfiles(inputpath, destination, chunks):
|
|
|
79
79
|
|
|
80
80
|
return filepath
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
def disk2fakefits(filetype, inputpath, destination, headerloc, arraysize, chunks=None):
|
|
83
|
+
# TODO: ADD code to handle arraysize differing from size of array in file
|
|
84
|
+
# maybe extend arr_size_check()?
|
|
85
|
+
destination = tempfile.TemporaryDirectory(dir=destination, delete=False)
|
|
85
86
|
match filetype:
|
|
86
87
|
case "fits":
|
|
87
88
|
f = fits.open(inputpath)
|
|
88
|
-
d = da.from_array(f[0].data, chunks=chunks)
|
|
89
|
-
destination = tempfile.TemporaryDirectory(dir=destination, delete=False)
|
|
89
|
+
d = da.from_array(f[0].data[arraysize], chunks=chunks)
|
|
90
90
|
n_header = dict2header(header_dict(f[0].header))
|
|
91
91
|
wcs_obj = wcs.WCS(n_header)
|
|
92
|
-
print(d.shape)
|
|
93
|
-
for i in range(d.blocks.shape[0]):
|
|
94
|
-
x = i * chunks[0]
|
|
95
|
-
x_delt = x + chunks[0] - 1
|
|
96
|
-
for j in range(d.blocks.shape[1]):
|
|
97
|
-
data = d.blocks[i][j]
|
|
98
|
-
y = j * chunks[1]
|
|
99
|
-
y_delt = y + chunks[1] - 1
|
|
100
|
-
if len(d.blocks.shape) == 2:
|
|
101
|
-
dest = str(i) + str(j)
|
|
102
|
-
wcs_coords = wcs_obj.slice((slice(x,x_delt), slice(y,y_delt)))
|
|
103
|
-
elif len(d.blocks.shape) > 2:
|
|
104
|
-
for k in range(d.blocks.shape[2]):
|
|
105
|
-
data = d.blocks[i][j][k]
|
|
106
|
-
z = k * chunks[2]
|
|
107
|
-
z_delt = z + chunks[2] - 1
|
|
108
|
-
dest = str(i) + str(j) + str(k)
|
|
109
|
-
t =wcs_obj[x:x_delt, y:y_delt, z:z_delt]
|
|
110
|
-
n_header.update(t.to_header())
|
|
111
|
-
hdu = fits.PrimaryHDU(data=data, header=n_header)
|
|
112
|
-
hdu.writeto(destination.name + dest + "fits")
|
|
113
|
-
fpath.append(destination.name + dest + "fits")
|
|
114
92
|
case "zarr":
|
|
115
|
-
|
|
93
|
+
d = da.from_zarr(inputpath, chunks=chunks)[arraysize]
|
|
94
|
+
n_header = dict2header(file2dict(inputpath, headerloc))
|
|
95
|
+
wcs_obj = wcs.WCS(n_header)
|
|
116
96
|
case "hdf5":
|
|
117
|
-
|
|
97
|
+
f = h5py.File(filepath, "r")
|
|
98
|
+
#note this is hardcoded for the particular hdf5 files tested - needs parameterisation
|
|
99
|
+
d = da.from_array(f["array"][arraysize], chunks=chunks)
|
|
100
|
+
n_header = dict2header(file2dict(inputpath, headerloc))
|
|
101
|
+
wcs_obj = wcs.WCS(n_header)
|
|
102
|
+
|
|
118
103
|
case "xradio":
|
|
119
104
|
weeble
|
|
120
105
|
case _:
|
|
121
106
|
raise ValueError("The specified file type is not supported by fits2tmp.")
|
|
122
|
-
return
|
|
123
|
-
|
|
107
|
+
return [d, destination, n_header, wcs_obj]
|
|
108
|
+
|
|
109
|
+
def fakefits2tmpfiles(filetype, inputpath, destination, headerloc, arraysize, chunks=None):
|
|
110
|
+
inputarray = disk2fakefits(filetype, inputpath, destination, headerloc, arraysize, chunks)
|
|
111
|
+
darr = inputarray[0]
|
|
112
|
+
destination = inputarray[1]
|
|
113
|
+
header = inputarray[2]
|
|
114
|
+
wcs_obj = inputarray[3]
|
|
115
|
+
dd = darr.to_delayed()
|
|
116
|
+
fpaths = []
|
|
117
|
+
for i in range(len(darr.chunks[0])):
|
|
118
|
+
x = i * chunks[0]
|
|
119
|
+
x_delt = x + chunks[0] - 1
|
|
120
|
+
for j in range(len(darr.chunks[1])):
|
|
121
|
+
print(i,j)
|
|
122
|
+
y = j * chunks[1]
|
|
123
|
+
y_delt = y + chunks[1] - 1
|
|
124
|
+
if len(darr.shape) == 2:
|
|
125
|
+
dest = str(i) + str(j)
|
|
126
|
+
data = dd[i][j]
|
|
127
|
+
wcs_coords = wcs_obj.slice((slice(x,x_delt), slice(y,y_delt)))
|
|
128
|
+
elif len(darr.shape) > 2:
|
|
129
|
+
for k in range(len(darr.chunks[2])):
|
|
130
|
+
print(k)
|
|
131
|
+
data = dd[i][j][k]
|
|
132
|
+
z = k * chunks[2]
|
|
133
|
+
z_delt = z + chunks[2] - 1
|
|
134
|
+
dest = '-' + str(i) +'-' + str(j) + '-' + str(k)
|
|
135
|
+
t = wcs_obj[x:x_delt, y:y_delt, z:z_delt]
|
|
136
|
+
header.update(t.to_header())
|
|
137
|
+
hdu = fits.PrimaryHDU(data=data.compute(), header=header)
|
|
138
|
+
hdu.writeto(destination.name + dest + "fits")
|
|
139
|
+
fpaths.append(destination.name + dest + "fits")
|
|
140
|
+
return fpaths
|
|
124
141
|
#def array2disk(array, metadata, outputtype, destination):
|
|
125
142
|
|
|
126
143
|
#def tmpfitsfile2disk(fitsfile, outputtype, destination):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|