Commit 6b47c762 authored by Carl Schaffer's avatar Carl Schaffer
Browse files

Merge branch 'bbi_cleaning' into 'master'

Bbi cleaning

Closes #285

See merge request !212
parents 09bc3c43 d55d5233
......@@ -10,12 +10,12 @@ import yaml
from import fits
from sunpy.coordinates.sun import earth_distance
from kis_tools.bbi.util import get_bbi_wl
from kis_tools.generic.settings import settings
from kis_tools.bbi.util import get_wl
from kis_tools.generic.settings.settings import get_settings
from kis_tools.interface import BasicArgParser
from kis_tools.util.util import setup_outdir
from .bbi_sort_observations import get_obs_info
from kis_tools.generic.settings.settings import get_settings
from ..util.util import add_history, date_from_fn
from ..util.util import get_filter
......@@ -412,7 +412,7 @@ def run_bbi_header_conversion(args):
new_header = convert_bbi_header(
wl = get_wl(new_header["FILENAME"])
wl = get_bbi_wl(new_header["FILENAME"])
out_dir = join(out_folder, new_header["POINT_ID"] + f"_WL{wl}")
......@@ -4,7 +4,7 @@ from itertools import groupby
from os.path import join, basename
from pprint import pprint
from kis_tools.bbi.util import get_wl
from kis_tools.bbi.util import get_bbi_wl
from kis_tools.util.util import merge_to_gif, gif_to_mp4
......@@ -18,8 +18,8 @@ def bbi_gen_gif(folder):
if not files:
grouped = groupby(files, get_wl)
grouped = groupby(files, get_bbi_wl)
for group, grouped_files in grouped:
grouped_files = list(grouped_files)
......@@ -7,12 +7,10 @@ Created by schaffer at 9/9/19
import argparse
import warnings
from glob import glob
from os.path import basename
from warnings import catch_warnings
import matplotlib as mpl
from pypeline import pipeline
from tqdm import tqdm
......@@ -49,22 +47,6 @@ def map_preview(fits_file, fn_out):
return fn_out
def alpha_preview(fits_file, fn_out):
"""Generate a preview of the estimated seeing quality over the different reconstruction subfields."""
datetime = FitsFile(fits_file).obs_time
format_keys = dict(
date=datetime.strftime("%Y%m%d"), time=datetime.strftime("%H%M%S")
log = glob(
if not log:
raise IOError(f"Could not find reconstruction results for {fits_file}")
speck = pipeline.speckle(log[0])
speck.plot_info_alpha(save=True, filename=fn_out)
return fn_out
def run_bbi_preview(cmd_line_args):
from ..interface.commandline_interface import add_arg_infiles
......@@ -83,7 +65,6 @@ def run_bbi_preview(cmd_line_args):
map_preview(infile, fn_out_reco)
loc_preview(infile, fn_out_loc)
alpha_preview(infile, fn_out_alpha)
# folder = dirname(infiles[0])
import re
def get_wl(fn):
"""Extract wavelength from string"""
return int("WL(\d+)", fn).group(1))
class NoWavelengthError(Exception):
def get_bbi_wl(fn):
"""Extract wavelength from string formatted as WL656 indicating 656nm wavelenght.
Returns: wavelength in nm
match ="WL(\d+)", fn)
if not match:
raise NoWavelengthError(f"Could not determine wavelength from {fn}, expeced a wavelength format like 'WLXXX'")
return int(
......@@ -9,6 +9,7 @@ from pprint import pprint
from unittest import TestCase
from kis_tools.bbi.bbi_header import get_generic_header
from kis_tools.bbi.util import get_bbi_wl, NoWavelengthError
from kis_tools.generic.settings.settings import get_settings
......@@ -21,3 +22,11 @@ class TestBBI(TestCase):
def test_bbi_header(self):
header = get_generic_header()
def test_get_wl(self):
working_teststrings = ["20170522_003_WL854", "bbi_20170523-092204_001_WL589_location_preview.png", ]
for ts in working_teststrings:
self.assertIsInstance(get_bbi_wl(ts), int)
error_teststrings = ["20170522_003_WLABC", "bbi_20170523-092204_001_location_preview.png", ]
for ts in error_teststrings:
self.assertRaises(NoWavelengthError, get_bbi_wl, ts)
......@@ -9,7 +9,7 @@ with open("") as f:
info = get_git_info(force=True)
version = "3.5.6"
version = "3.6.0"
with open('requirements.txt', 'r') as req_file:
requirements = [line.strip() for line in req_file]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment