Skip to content

Commit

Permalink
update entry points, add noaa to sharp parser
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertJaro committed Oct 25, 2023
1 parent 8521e6f commit b0deb37
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 1 deletion.
2 changes: 2 additions & 0 deletions nf2/data/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def find_HARP(start_time, noaa_nums, client):
key=['NOAA_AR', 'HARPNUM'])
if len(ar_mapping) == 0:
return None
if noaa_nums is None or len(noaa_nums) == 0:
return {'HARP': list(ar_mapping['HARPNUM']), 'NOAA': list(ar_mapping['NOAA_AR'])}
for noaa_num in noaa_nums:
harpnum = ar_mapping[ar_mapping['NOAA_AR'] == int(noaa_num)]['HARPNUM']
if len(harpnum) > 0:
Expand Down
3 changes: 3 additions & 0 deletions nf2/data/download_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@
os.makedirs(args.download_dir, exist_ok=True)
client = drms.Client(email=(args.email), verbose=True)
download_HARP_series(args.harpnum, parse(args.t_start), args.duration, args.download_dir, client, args.series, download_error=args.no_error)

def main(): # workaround for entry_points
pass
22 changes: 22 additions & 0 deletions nf2/data/noaa_to_sharp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import argparse

import drms
from dateutil.parser import parse

from nf2.data.download import find_HARP

parser = argparse.ArgumentParser()
parser.add_argument('--time', type=str, required=True)
parser.add_argument('--email', type=str, required=True, help='email address for JSOC')
parser.add_argument('--noaa_nums', type=int, nargs='+', required=False, default=None)
args = parser.parse_args()

client = drms.Client(email=args.email, verbose=True)
time = parse(args.time)
harp_numbers = find_HARP(time, args.noaa_nums, client)

# print the HARP numbers
print(f"HARP numbers for {time.isoformat()}: {harp_numbers}")

def main(): # workaround for entry_points
pass
3 changes: 3 additions & 0 deletions nf2/evaluation/nf2_to_fits.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@
hdu = fits.PrimaryHDU(b)
hdul = fits.HDUList([hdu])
hdul.writeto(fits_path)

def main(): # workaround for entry_points
pass
4 changes: 4 additions & 0 deletions nf2/evaluation/nf2_to_npy.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@
b = load_cube(nf2_path, device, progress=True, strides=strides)

np.save(npy_path, b)


def main(): # workaround for entry_points
pass
5 changes: 4 additions & 1 deletion nf2/evaluation/nf2_to_vtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@
tau = None

save_vtk(b, vtk_path, 'B', scalar=tau, scalar_name='tau',
Mm_per_pix=state['Mm_per_pixel'] * strides)
Mm_per_pix=state['Mm_per_pixel'] * strides)

def main(): # workaround for entry_points
pass
4 changes: 4 additions & 0 deletions nf2/extrapolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,7 @@
save(save_path, nf2.model, data_module, config, height_mapping_model=nf2.height_mapping_model)
# clean up
data_module.clear()


def main(): # workaround for entry_points
pass
4 changes: 4 additions & 0 deletions nf2/extrapolate_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,7 @@
gradient_clip_val=0.1, reload_dataloaders_every_n_epochs=1,
check_val_every_n_epoch=args.training['check_val_every_n_epoch'] if 'check_val_every_n_epoch' in args.training else 1,)
trainer.fit(nf2, data_module)


def main(): # workaround for entry_points
pass
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
'console_scripts': [
'nf2-extrapolate = nf2.extrapolate:main',
'nf2-extrapolate-series = nf2.extrapolate_series:main',
'nf2-noaa-to-sharp = nf2.data.noaa_to_sharp:main',
'nf2-download = nf2.data.download_range:main',
'nf2-to-vtk = nf2.evaluation.nf2_to_vtk:main',
'nf2-to-npy = nf2.evaluation.nf2_to_vtk:main',
Expand Down

0 comments on commit b0deb37

Please sign in to comment.