package-style architecture

This commit is contained in:
2024-05-24 12:15:06 +02:00
parent 4e17f40534
commit fb4849df25
18 changed files with 26 additions and 15 deletions

View File

@@ -35,7 +35,7 @@ def main(target=None, proposal_id=None, infiles=None, output_dir="./data", crop=
# Background estimation
error_sub_type = 'freedman-diaconis' # sqrt, sturges, rice, scott, freedman-diaconis (default) or shape (example (51, 51))
subtract_error = 0.01
subtract_error = 0.50
display_bkg = True
# Data binning
@@ -51,7 +51,7 @@ def main(target=None, proposal_id=None, infiles=None, output_dir="./data", crop=
# Smoothing
smoothing_function = 'combine' # gaussian_after, weighted_gaussian_after, gaussian, weighted_gaussian or combine
smoothing_FWHM = 0.200 # If None, no smoothing is done
smoothing_FWHM = 0.150 # If None, no smoothing is done
smoothing_scale = 'arcsec' # pixel or arcsec
# Rotation

2
package/__init__.py Normal file
View File

@@ -0,0 +1,2 @@
from . import lib
from . import src

9
package/lib/__init__.py Normal file
View File

@@ -0,0 +1,9 @@
from . import background
from . import convex_hull
from . import cross_correlation
from . import deconvolve
from . import fits
from . import plots
from . import query
from . import reduction
from . import utils

View File

@@ -17,7 +17,7 @@ import matplotlib.dates as mdates
from matplotlib.colors import LogNorm
from matplotlib.patches import Rectangle
from datetime import datetime
from lib.plots import plot_obs
from .plots import plot_obs
from scipy.optimize import curve_fit

View File

@@ -13,7 +13,7 @@ import numpy as np
from os.path import join as path_join
from astropy.io import fits
from astropy.wcs import WCS
from lib.convex_hull import clean_ROI
from .convex_hull import clean_ROI
def get_obs_data(infiles, data_folder="", compute_flux=False):

View File

@@ -56,9 +56,9 @@ from astropy.io import fits
from astropy.coordinates import SkyCoord
from scipy.ndimage import zoom as sc_zoom
try:
from .utils import rot2D, princ_angle, sci_not
except ImportError:
from utils import rot2D, princ_angle, sci_not
except ModuleNotFoundError:
from lib.utils import rot2D, princ_angle, sci_not
def plot_obs(data_array, headers, rectangle=None, savename=None, plots_folder="", **kwargs):
@@ -975,8 +975,8 @@ class overplot_pol(align_maps):
px_scale = self.other_wcs.wcs.get_cdelt()[0]/self.wcs_UV.wcs.get_cdelt()[0]
self.X, self.Y = np.meshgrid(np.arange(stkI.shape[1]), np.arange(stkI.shape[0]))
self.U, self.V = pol*np.cos(np.pi/2.+pang*np.pi/180.), pol*np.sin(np.pi/2.+pang*np.pi/180.)
self.Q = self.ax_overplot.quiver(self.X[::step_vec, ::step_vec], self.Y[::step_vec, ::step_vec], self.U[::step_vec, ::step_vec], self.V[::step_vec, ::step_vec], units='xy', angles='uv', scale=1./self.vec_scale, scale_units='xy', pivot='mid',
headwidth=0., headlength=0., headaxislength=0., width=0.5, linewidth=0.8, color='white', edgecolor='black', transform=self.ax_overplot.get_transform(self.wcs_UV), label="{0:s} polarisation map".format(self.map_observer))
self.Q = self.ax_overplot.quiver(self.X[::step_vec, ::step_vec], self.Y[::step_vec, ::step_vec], self.U[::step_vec, ::step_vec], self.V[::step_vec, ::step_vec], units='xy', angles='uv', scale=px_scale/self.vec_scale, scale_units='xy', pivot='mid',
headwidth=0., headlength=0., headaxislength=0., width=2.0, linewidth=1.0, color='white', edgecolor='black', transform=self.ax_overplot.get_transform(self.wcs_UV), label="{0:s} polarisation map".format(self.map_observer))
# Display Stokes I as contours
if levels is None:

View File

@@ -49,12 +49,12 @@ from scipy.signal import fftconvolve
from astropy.wcs import WCS
from astropy import log
import warnings
from lib.deconvolve import deconvolve_im, gaussian_psf, gaussian2d, zeropad
from lib.convex_hull import image_hull, clean_ROI
from lib.background import bkg_fit, bkg_hist, bkg_mini
from lib.plots import plot_obs
from lib.utils import princ_angle
from lib.cross_correlation import phase_cross_correlation
from .deconvolve import deconvolve_im, gaussian_psf, gaussian2d, zeropad
from .convex_hull import image_hull, clean_ROI
from .background import bkg_fit, bkg_hist, bkg_mini
from .plots import plot_obs
from .utils import princ_angle
from .cross_correlation import phase_cross_correlation
log.setLevel('ERROR')

0
package/src/__init__.py Normal file
View File

View File

@@ -30,7 +30,7 @@ except get_error as err:
if fits_path is not None:
from astropy.io import fits
from src.lib.plots import pol_map
from lib.plots import pol_map
Stokes_UV = fits.open(fits_path)
p = pol_map(Stokes_UV, SNRp_cut=SNRp_cut, SNRi_cut=SNRi_cut, flux_lim=flux_lim)