rithwiks commited on
Commit
ef312f6
1 Parent(s): 999ced5

added csv pull

Browse files
Files changed (2) hide show
  1. utils/eval_baselines.py +14 -4
  2. utils/pull_hubble_csv.py +80 -0
utils/eval_baselines.py CHANGED
@@ -70,14 +70,23 @@ def main(dim):
70
 
71
  file_paths = find_matching_files()
72
 
73
- df = pd.DataFrame(columns=columns, index=[str(p) for p in file_paths])
 
 
 
 
74
 
75
  print(f"Number of files to be tested: {len(file_paths)}")
76
 
77
  ct = 0
 
 
78
 
79
  for path in tqdm(file_paths):
80
  for hdu_idx in [1, 4]:
 
 
 
81
  with fits.open(path) as hdul:
82
  if dim == '2d':
83
  arr = hdul[hdu_idx].data
@@ -86,7 +95,7 @@ def main(dim):
86
 
87
  ct += 1
88
  if ct % 10 == 0:
89
- print(df.mean())
90
  df.to_csv(save_path)
91
 
92
  for algo in ALL_CODECS.keys():
@@ -98,12 +107,13 @@ def main(dim):
98
 
99
  for column, value in test_results.items():
100
  if column in df.columns:
101
- df.at[path + f"_hdu{hdu_idx}", column] = value
102
 
103
  except Exception as e:
104
  print(f"Failed at {path} under exception {e}.")
105
 
106
-
 
107
  if __name__ == "__main__":
108
  parser = argparse.ArgumentParser(description="Process some 2D or 3D data.")
109
  parser.add_argument(
 
70
 
71
  file_paths = find_matching_files()
72
 
73
+ if os.path.isfile(save_path):
74
+ df = pd.read_csv(save_path)
75
+ else:
76
+ pass
77
+ #df = pd.DataFrame(columns=columns, index=[str(p) for p in file_paths])
78
 
79
  print(f"Number of files to be tested: {len(file_paths)}")
80
 
81
  ct = 0
82
+
83
+ #print(df)
84
 
85
  for path in tqdm(file_paths):
86
  for hdu_idx in [1, 4]:
87
+ df_idx = path + f"_hdu{hdu_idx}"
88
+ if df_idx in df[df.columns[0]].values:
89
+ continue
90
  with fits.open(path) as hdul:
91
  if dim == '2d':
92
  arr = hdul[hdu_idx].data
 
95
 
96
  ct += 1
97
  if ct % 10 == 0:
98
+ #print(df.mean())
99
  df.to_csv(save_path)
100
 
101
  for algo in ALL_CODECS.keys():
 
107
 
108
  for column, value in test_results.items():
109
  if column in df.columns:
110
+ df.at[df_idx, column] = value
111
 
112
  except Exception as e:
113
  print(f"Failed at {path} under exception {e}.")
114
 
115
+ df.to_csv(save_path)
116
+
117
  if __name__ == "__main__":
118
  parser = argparse.ArgumentParser(description="Process some 2D or 3D data.")
119
  parser.add_argument(
utils/pull_hubble_csv.py ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from astroquery.mast.missions import MastMissions
2
+
3
+ """
4
+ Used to pull the list of observations that fit our filter criteria from
5
+ online Hubble archives. See all filter details in the function call below.
6
+ """
7
+
8
+ missions = MastMissions(mission='hst')
9
+
10
+ # Use query_criteria method to use selected form search conditions for making missions_mast search API call
11
+ results = missions.query_criteria(select_cols=[
12
+ 'sci_aec',
13
+ 'ang_sep',
14
+ 'sci_aper_1234',
15
+ 'sci_archive_class',
16
+ 'sci_archive_date',
17
+ 'sci_asn_id',
18
+ 'sci_bandwidth',
19
+ 'sci_broad_category',
20
+ 'sci_central_wavelength',
21
+ 'sci_costar_deploy',
22
+ 'sci_data_set_name',
23
+ 'sci_dec',
24
+ 'sci_dec_v1',
25
+ 'sci_dispersion',
26
+ 'sci_ecliptic_latitude',
27
+ 'sci_ecliptic_longitude',
28
+ 'sci_expflag',
29
+ 'sci_actual_duration',
30
+ 'sci_fgslock',
31
+ 'sci_spec_1234',
32
+ 'sci_fov_config',
33
+ 'sci_galactic_latitude',
34
+ 'sci_galactic_longitude',
35
+ 'sci_generation_date',
36
+ 'sci_hapnum',
37
+ 'sci_haspnum',
38
+ 'sci_hlsp',
39
+ 'sci_instrume',
40
+ 'sci_instrument_config',
41
+ 'sci_mtflag',
42
+ 'sci_obs_type',
43
+ 'sci_obset_id',
44
+ 'sci_obsnum',
45
+ 'sci_operating_mode',
46
+ 'sci_pa_aper',
47
+ 'sci_pi_last_name',
48
+ 'sci_pixel_res',
49
+ 'sci_preview_name',
50
+ 'sci_program_id',
51
+ 'sci_pep_id',
52
+ 'sci_ra',
53
+ 'sci_ra_v1',
54
+ 'sci_refnum',
55
+ 'sci_release_date',
56
+ 'scp_scan_type',
57
+ 'sci_spectral_res',
58
+ 'sci_spectrum_end',
59
+ 'sci_spectrum_start',
60
+ 'sci_start_time',
61
+ 'sci_status',
62
+ 'sci_stop_time',
63
+ 'sci_sun_alt',
64
+ 'sci_target_descrip',
65
+ 'sci_targname',
66
+ 'sci_v3_pos_angle'],
67
+ sci_spec_1234='F606W,F606W;*,*;F606W,*;F606W;*',
68
+ sci_aec='S',
69
+ sci_instrume='acs',
70
+ sci_instrument_config='ACS/WFC',
71
+ sci_expflag='NORMAL',
72
+ sci_actual_duration='>300',
73
+ sci_aper_1234='WFC,WFC1,WFC2,WFCENTER',
74
+ limit=25000
75
+
76
+ )
77
+
78
+ df = results.to_pandas()
79
+ print(len(df))
80
+ df.to_csv('hst_FINAL.csv')