fits2tmp 0.1.9__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.9 → fits2tmp-0.2.0}/PKG-INFO +1 -1
- {fits2tmp-0.1.9 → fits2tmp-0.2.0}/pyproject.toml +1 -1
- fits2tmp-0.2.0/src/fits2tmp/dask-output.log +0 -0
- {fits2tmp-0.1.9 → fits2tmp-0.2.0}/src/fits2tmp/fits2tmp.py +35 -21
- {fits2tmp-0.1.9 → fits2tmp-0.2.0}/LICENSE +0 -0
- {fits2tmp-0.1.9 → fits2tmp-0.2.0}/README.md +0 -0
- {fits2tmp-0.1.9 → fits2tmp-0.2.0}/src/fits2tmp/__init__.py +0 -0
- {fits2tmp-0.1.9 → fits2tmp-0.2.0}/src/fits2tmp/sdc2_100.fits +0 -0
- {fits2tmp-0.1.9 → fits2tmp-0.2.0}/src/fits2tmp/sofiatestrewrite1002_cat.txt +0 -0
- {fits2tmp-0.1.9 → fits2tmp-0.2.0}/src/fits2tmp/sofiatestrewrite1002_cat.xml +0 -0
- {fits2tmp-0.1.9 → fits2tmp-0.2.0}/src/fits2tmp/sofiatestrewrite100_cat.txt +0 -0
- {fits2tmp-0.1.9 → 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,50 +79,64 @@ def fits2tmpfiles(inputpath, destination, chunks):
|
|
|
79
79
|
|
|
80
80
|
return filepath
|
|
81
81
|
|
|
82
|
-
def disk2fakefits(filetype, inputpath, destination, arraysize, chunks=None):
|
|
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)
|
|
83
86
|
match filetype:
|
|
84
87
|
case "fits":
|
|
85
88
|
f = fits.open(inputpath)
|
|
86
|
-
d = da.from_array(f[0].data, chunks=chunks)
|
|
87
|
-
destination = tempfile.TemporaryDirectory(dir=destination, delete=False)
|
|
89
|
+
d = da.from_array(f[0].data[arraysize], chunks=chunks)
|
|
88
90
|
n_header = dict2header(header_dict(f[0].header))
|
|
89
91
|
wcs_obj = wcs.WCS(n_header)
|
|
90
92
|
case "zarr":
|
|
91
|
-
|
|
93
|
+
d = da.from_zarr(inputpath, chunks=chunks)[arraysize]
|
|
94
|
+
n_header = dict2header(file2dict(inputpath, headerloc))
|
|
95
|
+
wcs_obj = wcs.WCS(n_header)
|
|
92
96
|
case "hdf5":
|
|
93
|
-
|
|
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
|
+
|
|
94
103
|
case "xradio":
|
|
95
104
|
weeble
|
|
96
105
|
case _:
|
|
97
106
|
raise ValueError("The specified file type is not supported by fits2tmp.")
|
|
98
|
-
return d, destination, n_header, wcs_obj
|
|
99
|
-
|
|
100
|
-
def fakefits2tmpfiles(filetype, inputpath, destination, arraysize, chunks=None):
|
|
101
|
-
|
|
102
|
-
|
|
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]
|
|
103
115
|
dd = darr.to_delayed()
|
|
104
116
|
fpaths = []
|
|
105
|
-
for i in range(
|
|
117
|
+
for i in range(len(darr.chunks[0])):
|
|
106
118
|
x = i * chunks[0]
|
|
107
119
|
x_delt = x + chunks[0] - 1
|
|
108
|
-
for j in range(
|
|
120
|
+
for j in range(len(darr.chunks[1])):
|
|
121
|
+
print(i,j)
|
|
109
122
|
y = j * chunks[1]
|
|
110
123
|
y_delt = y + chunks[1] - 1
|
|
111
|
-
if len(
|
|
124
|
+
if len(darr.shape) == 2:
|
|
112
125
|
dest = str(i) + str(j)
|
|
113
126
|
data = dd[i][j]
|
|
114
127
|
wcs_coords = wcs_obj.slice((slice(x,x_delt), slice(y,y_delt)))
|
|
115
|
-
elif len(
|
|
116
|
-
for k in range(
|
|
128
|
+
elif len(darr.shape) > 2:
|
|
129
|
+
for k in range(len(darr.chunks[2])):
|
|
130
|
+
print(k)
|
|
117
131
|
data = dd[i][j][k]
|
|
118
132
|
z = k * chunks[2]
|
|
119
133
|
z_delt = z + chunks[2] - 1
|
|
120
|
-
dest = str(i) + str(j) + str(k)
|
|
121
|
-
t =wcs_obj[x:x_delt, y:y_delt, z:z_delt]
|
|
122
|
-
|
|
123
|
-
hdu = fits.PrimaryHDU(data=data.compute(), header=
|
|
124
|
-
hdu.writeto(
|
|
125
|
-
fpaths.append(
|
|
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")
|
|
126
140
|
return fpaths
|
|
127
141
|
#def array2disk(array, metadata, outputtype, destination):
|
|
128
142
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|