import numpy as np import json import os from pyarchi.utils import create_logger logger = create_logger("util") def get_file_name(path, storage_location): """ Extracts the last part of the path, i.e. the dataset folder name, to store the optimized masks Example --------- >>> get_file_name("kamuish/teste") >>> "teste" >>> get_file_name("kamuish/teste/") >>> "teste" Parameters ---------- path : string path to the base folder """ splitted_path = path.split("/") file_name = splitted_path[-2] if not splitted_path[-1] else splitted_path[ -1] json_full_path = os.path.join(storage_location, "{}.json".format(file_name))
from astropy.io import fits import numpy as np from .Mask import Masks from pyarchi.utils import path_finder from pyarchi.utils import create_logger, CDPP logger = create_logger("star_track") class Star: """ Star class that holds the star information. We have a class attribute, number, that will be used to name the star. Each star increments this number by one. Parameters --------------- cdpp_type: CDPP algorithm; Can be a string or a function. If it is a string, it should be "K2". Otherwise, the function should have the format def foo(flux, time): return metric pos=None: Initial position dist = None: Distance to center Notes ----------- name:
import yaml from functools import wraps from .photometric_process import photometry from pyarchi.data_objects import Data from pyarchi.utils import general_optimizer, store_optimized_radius from pyarchi.utils import create_logger, parameters_validator logger = create_logger("Photo Controller") class Photo_controller: """ Controller class that allows an easy interface with all the important functions in the module. If the no_optim parameter is set to False, then it automatically starts the optimization routine, at instantiation time of the class. """ def __init__(self, job_number, config_path="configuration_files/config.yaml", no_optim=False): self.job_number = job_number logger.info("Loading Parameters:") if isinstance(config_path, str): with open(config_path, "r") as stream: kwargs = yaml.load(stream) else: # we can pass a dict kwargs = config_path self.kwargs = kwargs self.data_fits = Data(kwargs['base_folder'])
import matplotlib.pyplot as plt import os from pyarchi.utils import export_txt, create_fits, photo_SaveInfo from pyarchi.data_objects import Data from .photometry_outputs import photom_plots from pyarchi.utils import handle_folders from pyarchi.utils import create_logger logger = create_logger("Output creation") def store_data(data_fits, job_number, singular=None, **kwargs): """ Stores the data extracted from the entire pipeline. Like the controllers, it can work with a :class:`~pyarchi.data_objects.Data.Data` object that was used for both parts or only for one of them. If one wishes, it can also only create the folders and extract the data only for the chosen star. Parameters ---------- data_fits: :class:`~pyarchi.data_objects.Data.Data` object. job_number: Job number, from the supernova server. Will be used to save the parent folder inside the kwargs["results_folder"] to create the entire directory structure. singular: If it's not None, then only that star's light curve is saved. Only works for the "show_results".
import numpy as np from pyarchi.utils import create_logger logger = create_logger("masks") class Masks: """ Class used to hold the mask for each iteration, as well as some of some important methods """ def __init__(self, mask_factor, grid_increase, initial_mask, low_memory=0): self._mask_factor = mask_factor self.grid_increase = grid_increase self._masks = [] self._low_mem = low_memory self._mask_size = len(np.where(initial_mask != 0)[0]) self.add_mask(initial_mask) def add_mask(self, mask): """ Stores a new mask. If the low memory mode is active, only two masks are stored in memory: the initial one and the latest. Parameters ---------- mask: Mask to be added
import numpy as np from astropy.io import fits from pyarchi.utils import path_finder from pyarchi.utils.misc.rotation_mats import matrix_cnter_clock from pyarchi.utils import create_logger from pyarchi.data_objects import Star logger = create_logger("initial_detection") def centers_from_fits(primary, secondary, stars, initial_angle,initial_offset, **kwargs): """ Using information stored on the fits files, we determine the centers positions. The centers are determined using relations between the differences in RA and DEC of all stars in relation to the known point : the central star. After determining the center, we use the primary and secondary arguments to see if this function should change the initial position of the star. Parameters ---------- primary: str Methodology to apply to the central star. If it's fits then the initial position of that star is changed to be the one determined here. secondary: str Methodology to apply to the outer stars. If it's fits then the initial position of those stars are changed to be the ones determined here. stars: list List with all the stars found with the dynam method initial_angle: float Rotation angle of the satellite for the first image initial_offset: list
from astropy.io import fits import numpy as np from pyarchi.masks_creation import create_circular_mask, create_shape_mask from pyarchi.masks_creation import change_grid from pyarchi.initial_detection import centers_from_fits, initial_dynam_centers from pyarchi.utils.misc.rotation_mats import matrix_cnter_clock, matrix_clockwise from pyarchi.utils import path_finder from pyarchi.utils import get_optimized_mask from pyarchi.utils import create_logger from .Star_class import Star logger = create_logger("Data") class Data: """ Data structure to hold the information of all the stars in the field. Parameters --------------- base_folder: location of the folder in which all the fits files are located. roll_ang: rotation angle for all the images. imgs: all the images in the fits file. stars:
from matplotlib import pyplot as plt import numpy as np import os from pyarchi.star_track import star_tracking_handler from pyarchi.utils import my_timer from pyarchi.utils import create_logger logger = create_logger("main") @my_timer def photometry(data_fits, save_folder, **kwargs): """ This function ensures that the entire process runs in the correct order. First the masks are updated and, afterwards, the centers for the next image are calculated. Parameters ------------------ data_fits: Object of "Data" class that will hold the results of the analysis for each star kwargs: dictionary with all the necessary information. It is loaded from the config.yaml file Returns ------------------ data_fits: Object of "Data" class that holds the results of the analysis for each star -1: If an error was found during the process """ if not kwargs[