-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPTRrenamer.py
More file actions
80 lines (57 loc) · 2.15 KB
/
PTRrenamer.py
File metadata and controls
80 lines (57 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 21 20:29:20 2025
@author: WER
"""
import os
import glob
import pathlib
import shutil
import time
from astropy.io import fits
# =============================================================================
# fits_image_filename = fits.util.get_testdata_filepath('test0.fits')
# hdul = fits.open(fits_image_filename)
# hdul.info()
# hdul[0].header['DATE']
# =============================================================================
eva = 'F://ptr//aro1//archive//sq003ms//*//reduced//*.fits'
def main_routine(first_run=False):
big_list = glob.glob(eva)[:-3]
#big_list.reverse()
#big_list = big_list[40:]
print(big_list)
for image_filename in big_list:
with fits.open(image_filename) as hdu1:
hdr = hdu1[0].header
pane = str(hdr['Pane'])
if len(pane) < 2:
pane = "-P0"+str(pane)+'.fts'
else:
pane = "-P"+str(pane)+'.fts'
new_filename = image_filename[:-5] + pane
shutil.copy(image_filename, new_filename)
breakpoint()
# for directory in big_list:
# # print("Globbing: "+ directory)
# if count == 1:
# break
# stack_list = glob.glob(directory + '//fits//SmStack-*.fits')
# print(stack_list)
# target = 'X://PTRnames//'+ directory.split('\\')[1]
# os.makedirs(target , exist_ok=True)
# for image_filename in big_list:
# with fits.open(image_filename) as hdu1:
# hdr = hdu1[0].header
# breakpoint()
# origin_name = hdr['ORIGNAME'].split('_expose_')
# ptr_name = origin_name[0]+ '-' + hdr['OBJECT'] + '-' + origin_name[1]
# hdu1.close()
# shutil.copy(image_filename, target + "//" + ptr_name)
# print("Copied: ", target + "//" + ptr_name)
# moved.append(image_filename)
# count += 1
print ("DONE")
if __name__ == '__main__':
print('bingo')
main_routine(first_run=True)