fits2tmp 0.2.0__tar.gz → 0.3.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.
@@ -0,0 +1,50 @@
1
+ Metadata-Version: 2.3
2
+ Name: fits2tmp
3
+ Version: 0.3.0
4
+ Summary: A way of loading FITS files into temporary filesystems to make them available in memory.
5
+ License: BSD-3-Clause
6
+ Author: Verity Allan
7
+ Author-email: vla22@cam.ac.uk
8
+ Requires-Python: >=3.10,<4.0
9
+ Classifier: License :: OSI Approved :: BSD License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Requires-Dist: astropy (>=6.1.4,<7.0.0)
16
+ Requires-Dist: dask[distributed] (>=2025.1.0,<2026.0.0)
17
+ Requires-Dist: h5py (>=3.12.1,<4.0.0)
18
+ Requires-Dist: numpy (>=2.1.2,<3.0.0)
19
+ Requires-Dist: pytest (>=8.3.3,<9.0.0)
20
+ Requires-Dist: zarr (>=2.18.3,<3.0.0)
21
+ Project-URL: Repository, https://gitlab.developers.cam.ac.uk/phy/ra/vla22-phd/fits2tmp
22
+ Description-Content-Type: text/markdown
23
+
24
+ # fits2tmp
25
+
26
+ This project allows you to take a large FITS file and render it as a set of smaller FITS files stored in-memory in a temporary directory, with appropriately updated headers.
27
+ The program returns a list of the location of these files, which can then be processed by a parallel processing framework such as dask.
28
+
29
+ The program also allows you to turn a zarr file containing your FITS data into small FITS files, provided you have extracted the FITS file header to a text file.
30
+ Utilities in the program can be used to write headers out to or read them from a text file.
31
+
32
+ ## TODO:
33
+
34
+ - Add a utility to convert FITS files to zarr, including saving the header out to a text file.
35
+ - Add hdf5 support using a similar strategy to FITS.
36
+ - Add xradio support.
37
+
38
+ ## Installing fits2tmp
39
+
40
+ The program is available from pypi so can be installed with pip: `pip install fits2tmp`.
41
+
42
+ ## Example Usage
43
+
44
+ ```
45
+ import fits2tmp as f2t
46
+
47
+ a = fakefits2tmpfiles("fits", "/path/to/input/data", "/path/to/temporary/filesystem", "path/to/header/", (100, 100, 100), chunks=(20,20,20))
48
+ ```
49
+
50
+
@@ -0,0 +1,26 @@
1
+ # fits2tmp
2
+
3
+ This project allows you to take a large FITS file and render it as a set of smaller FITS files stored in-memory in a temporary directory, with appropriately updated headers.
4
+ The program returns a list of the location of these files, which can then be processed by a parallel processing framework such as dask.
5
+
6
+ The program also allows you to turn a zarr file containing your FITS data into small FITS files, provided you have extracted the FITS file header to a text file.
7
+ Utilities in the program can be used to write headers out to or read them from a text file.
8
+
9
+ ## TODO:
10
+
11
+ - Add a utility to convert FITS files to zarr, including saving the header out to a text file.
12
+ - Add hdf5 support using a similar strategy to FITS.
13
+ - Add xradio support.
14
+
15
+ ## Installing fits2tmp
16
+
17
+ The program is available from pypi so can be installed with pip: `pip install fits2tmp`.
18
+
19
+ ## Example Usage
20
+
21
+ ```
22
+ import fits2tmp as f2t
23
+
24
+ a = fakefits2tmpfiles("fits", "/path/to/input/data", "/path/to/temporary/filesystem", "path/to/header/", (100, 100, 100), chunks=(20,20,20))
25
+ ```
26
+
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "fits2tmp"
3
- version = "0.2.0"
3
+ version = "0.3.0"
4
4
  description = "A way of loading FITS files into temporary filesystems to make them available in memory."
5
5
  license = "BSD-3-Clause"
6
6
  authors = ["Verity Allan <vla22@cam.ac.uk>"]
@@ -79,14 +79,15 @@ def fits2tmpfiles(inputpath, destination, chunks):
79
79
 
80
80
  return filepath
81
81
 
82
- def disk2fakefits(filetype, inputpath, destination, headerloc, arraysize, chunks=None):
82
+ def disk2dah(filetype, inputpath, destination, headerloc, arraysize, chunks=None):
83
83
  # TODO: ADD code to handle arraysize differing from size of array in file
84
84
  # maybe extend arr_size_check()?
85
+ # TODO make this support arrays that have other than 3 dims
85
86
  destination = tempfile.TemporaryDirectory(dir=destination, delete=False)
86
87
  match filetype:
87
88
  case "fits":
88
89
  f = fits.open(inputpath)
89
- d = da.from_array(f[0].data[arraysize], chunks=chunks)
90
+ d = da.from_array(f[0].data[0:arraysize[0], 0:arraysize[1], 0:arraysize[2]], chunks=chunks)
90
91
  n_header = dict2header(header_dict(f[0].header))
91
92
  wcs_obj = wcs.WCS(n_header)
92
93
  case "zarr":
@@ -106,31 +107,51 @@ def disk2fakefits(filetype, inputpath, destination, headerloc, arraysize, chunks
106
107
  raise ValueError("The specified file type is not supported by fits2tmp.")
107
108
  return [d, destination, n_header, wcs_obj]
108
109
 
109
- def fakefits2tmpfiles(filetype, inputpath, destination, headerloc, arraysize, chunks=None):
110
- inputarray = disk2fakefits(filetype, inputpath, destination, headerloc, arraysize, chunks)
110
+ def fakefits2tmpfiles(filetype, inputpath, destination, arraysize, headerloc=None, chunks=None, overlap=None):
111
+ inputarray = disk2dah(filetype, inputpath, destination, headerloc, arraysize, chunks)
112
+ if overlap == None:
113
+ overlap = [0,0,0]
111
114
  darr = inputarray[0]
115
+ print(darr.shape)
116
+ print(darr)
112
117
  destination = inputarray[1]
113
118
  header = inputarray[2]
119
+ print(header)
114
120
  wcs_obj = inputarray[3]
115
- dd = darr.to_delayed()
121
+ print(len(darr.chunks))
122
+ # why am I pushing this array to delayed? ans: to parallelise construction of the list
123
+ #dd = darr.to_delayed()
116
124
  fpaths = []
117
125
  for i in range(len(darr.chunks[0])):
118
- x = i * chunks[0]
119
- x_delt = x + chunks[0] - 1
126
+ x = i * chunks[0] - overlap[0]
127
+ x_delt = (i* chunks[0]) + chunks[0] + overlap[0]
128
+ # range check - when asking for overlap, we curtail at the edges of the array
129
+ if x < 0:
130
+ x = 0
131
+ if x_delt > arraysize[0] -1:
132
+ x_delt = arraysize[0]
133
+ print(x, x_delt)
120
134
  for j in range(len(darr.chunks[1])):
121
- print(i,j)
122
- y = j * chunks[1]
123
- y_delt = y + chunks[1] - 1
135
+ y = j * chunks[1] - overlap[1]
136
+ y_delt = (j * chunks[1]) + chunks[1] + overlap[1]
137
+ if y < 0:
138
+ y = 0
139
+ if y_delt > arraysize[1] -1:
140
+ y_delt = arraysize[1]
124
141
  if len(darr.shape) == 2:
125
142
  dest = str(i) + str(j)
126
143
  data = dd[i][j]
127
144
  wcs_coords = wcs_obj.slice((slice(x,x_delt), slice(y,y_delt)))
128
145
  elif len(darr.shape) > 2:
129
146
  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
147
+ z = k * chunks[2] - overlap[2]
148
+ z_delt = (k * chunks[2]) + chunks[2] + overlap[2]
149
+ if z < 0:
150
+ z = 0
151
+ if z_delt > arraysize[2] -1:
152
+ z_delt = arraysize[2]
153
+ data = darr[x:x_delt, y:y_delt, z:z_delt]
154
+ print(data.shape)
134
155
  dest = '-' + str(i) +'-' + str(j) + '-' + str(k)
135
156
  t = wcs_obj[x:x_delt, y:y_delt, z:z_delt]
136
157
  header.update(t.to_header())
fits2tmp-0.2.0/PKG-INFO DELETED
@@ -1,31 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: fits2tmp
3
- Version: 0.2.0
4
- Summary: A way of loading FITS files into temporary filesystems to make them available in memory.
5
- Home-page: https://gitlab.developers.cam.ac.uk/phy/ra/vla22-phd/fits2tmp
6
- License: BSD-3-Clause
7
- Author: Verity Allan
8
- Author-email: vla22@cam.ac.uk
9
- Requires-Python: >=3.10,<4.0
10
- Classifier: License :: OSI Approved :: BSD License
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.10
13
- Classifier: Programming Language :: Python :: 3.11
14
- Requires-Dist: astropy (>=6.1.4,<7.0.0)
15
- Requires-Dist: dask[distributed] (>=2025.1.0,<2026.0.0)
16
- Requires-Dist: h5py (>=3.12.1,<4.0.0)
17
- Requires-Dist: numpy (>=2.1.2,<3.0.0)
18
- Requires-Dist: pytest (>=8.3.3,<9.0.0)
19
- Requires-Dist: zarr (>=2.18.3,<3.0.0)
20
- Project-URL: Repository, https://gitlab.developers.cam.ac.uk/phy/ra/vla22-phd/fits2tmp
21
- Description-Content-Type: text/markdown
22
-
23
- # Sample GitLab Project
24
-
25
- This sample project shows how a project in GitLab looks for demonstration purposes. It contains issues, merge requests and Markdown files in many branches,
26
- named and filled with lorem ipsum.
27
-
28
- You can look around to get an idea how to structure your project and, when done, you can safely delete this project.
29
-
30
- [Learn more about creating GitLab projects.](https://docs.gitlab.com/ee/gitlab-basics/create-project.html)
31
-
fits2tmp-0.2.0/README.md DELETED
@@ -1,8 +0,0 @@
1
- # Sample GitLab Project
2
-
3
- This sample project shows how a project in GitLab looks for demonstration purposes. It contains issues, merge requests and Markdown files in many branches,
4
- named and filled with lorem ipsum.
5
-
6
- You can look around to get an idea how to structure your project and, when done, you can safely delete this project.
7
-
8
- [Learn more about creating GitLab projects.](https://docs.gitlab.com/ee/gitlab-basics/create-project.html)
File without changes