Commit 3d71c8b9 authored by Francesco Amadori's avatar Francesco Amadori
Browse files

added limit t23

parent 4c1cdc4c
Loading
Loading
Loading
Loading
+52 −82
Original line number Diff line number Diff line
@@ -99,11 +99,13 @@ def get_target_info(path_targets_folder, target):
            yaml_file.get("inclination_deg", ""),
            yaml_file.get("v_sini_km_s", ""),
            yaml_file.get("Limit_Phase_T12", 0),
            yaml_file.get("Limit_Phase_T23", 0),
            yaml_file.get("t14_hours", 0),
            yaml_file.get("t12_hours", 0),
            yaml_file.get("t23_hours", 0),
        )
    else:
        return [None for _ in range(25)]
        return [None for _ in range(27)]


def get_target_nights(path_targets, target, rad_mode, instrument="GIANO_B", simulated=0):
@@ -139,7 +141,7 @@ def get_target_nights(path_targets, target, rad_mode, instrument="GIANO_B", simu
    return nights


def compute_transit_durations(period, a_Rs, k, inc_deg, ecc=0.0, omega=np.pi / 2, t14_def=None):
def compute_transit_durations(period, a_Rs, k, inc_deg, ecc=0.0, omega=np.pi / 2):
    """
    Compute transit durations T14, T23, T12 (=T34) for circular and eccentric orbits.

@@ -156,7 +158,7 @@ def compute_transit_durations(period, a_Rs, k, inc_deg, ecc=0.0, omega=np.pi / 2
    ecc : float, optional
        Orbital eccentricity (default 0 for circular).
    omega : float, optional
        Argument of periastron of the STAR in radians (default pi/2).
        Argument of periastron of the STAR in degrees (default 90).
    t14_def : float, optional
        Default transit duration T14 in hours (default None).

@@ -224,10 +226,10 @@ def compute_transit_durations(period, a_Rs, k, inc_deg, ecc=0.0, omega=np.pi / 2
    T23 = T23_circ * ecc_factor
    T12 = (T14 - T23) / 2.0

    if t14_def is not None:
        print(f"T14 set to {t14_def} hours (provided) instead of {T14 * 24} hours (calculated)")
        T14 = t14_def / 24.0

    limph_T14 = T14 / (2.0 * period)
    limph_T12 = T12 / (2.0 * period)
    limph_T23 = T23 / (2.0 * period)
    print(f"T14={T14 * 24:.2f}hours, T23={T23:.2f}hours, T12={T12:.2f}hours, limph_T14={limph_T14:.2f}, limph_T12={limph_T12:.2f}, limph_T23={limph_T23:.2f}")
    return {
        'T14': T14,
        'T23': T23,
@@ -238,14 +240,15 @@ def compute_transit_durations(period, a_Rs, k, inc_deg, ecc=0.0, omega=np.pi / 2
        'b': b,
        'ecc_factor': ecc_factor,
        'grazing': grazing,
        'limph_T14': T14 / (2.0 * period),
        'limph_T12': T12 / (2.0 * period),
        'limph_T14': limph_T14,
        'limph_T12': limph_T12,
        'limph_T23': limph_T23,
    }


def insert_target_catalog(
        path_target,
        target_id,
        path_target: Path,
        target_id: str,
        radius,
        mass,
        gravity,
@@ -258,90 +261,54 @@ def insert_target_catalog(
        vsys,
        limph_T14,
        limph_T12,
        limph_T23,
        kp,
        ks,
        ecc,
        t14,
        t12,
        t23,
        opi=1.57,
        stellar_teff=0,
        rad_mode="Transmission",
        ra=0,
        dec=0,
        a_Rs_ratio=0,
        projected_obliquity=0,
        inclination=0,
        v_sini=0
):
    """
    Create a new target entry in the catalog with its directory structure and info.yaml file.

    This function creates the necessary directory structure for a new target and writes
    its physical and orbital parameters to an info.yaml file.

    Parameters
    ----------
    path_target : str or Path
        Base path where the target directory will be created.
    target_id : str
        Name identifier for the target.
    radius : float
        Planet radius in Jupiter radii.
    mass : float
        Planet mass in Jupiter masses.
    gravity : float
        Surface gravity in cm/s^2.
    t_eq : float
        Equilibrium temperature in Kelvin.
    stellar_radius : float
        Stellar radius in solar radii.
    stellar_mass : float
        Stellar mass in solar masses.
    p0 : float
        Reference pressure in log10(bar).
    hjd0 : float
        Reference time of transit in HJD (days).
    period : float
        Orbital period in days.
    vsys : float
        System velocity in km/s.
    limph_T14 : float
        Phase limit for T14 transit.
    limph_T12 : float
        Phase limit for T12 transit.
    kp : float
        Planet's semi-amplitude velocity in km/s.
    ks : float
        Star's semi-amplitude velocity in km/s.
    ecc : float
        Orbital eccentricity.
    t14 : float
        Total transit duration T14 in hours.
    t12 : float
        Ingress/egress duration T12 in hours.
    opi : float, optional
        Periastron argument in radians. Default is 1.57 (π/2).
    stellar_teff : float, optional
        Stellar effective temperature in Kelvin. Default is 0.
    rad_mode : str, optional
        Radiation mode. Default is "Transmission".
    ra : float, optional
        Right ascension in degrees. Default is 0.
    dec : float, optional
        Declination in degrees. Default is 0.
    a_Rs_ratio : float, optional
        Stellar radiation ratio. Default is 0.
    projected_obliquity : float, optional
        Projected obliquity in degrees. Default is 0.
    inclination : float, optional
        Inclination in degrees. Default is 0.
    v_sini : float, optional
        Stellar velocity in km/s. Default is 0.

    Returns
    -------
    None
        Creates directories and writes info.yaml file.
) -> None:
    """Create a new target catalog entry with associated directories.

    Args:
        path_target (Path): Base path for targets
        target_id (str): Target identifier
        radius : Radius in Jupiter radii
        mass : Mass in Jupiter masses
        gravity : Surface gravity in cm/s²
        t_eq : Equilibrium temperature in Kelvin
        stellar_radius : Stellar radius in solar radii
        stellar_mass : Stellar mass in solar masses
        p0 : Reference pressure in log10(bar)
        hjd0 : Reference HJD in days
        period : Orbital period in days
        vsys : Systemic velocity in km/s
        limph_T14 : Phase limit in hours for T14 transit
        limph_T12 : Phase limit in hours for T12 transit
        limph_T23 : Phase limit in hours for T23 transit
        kp : Planet Semi-amplitude in km/s
        ks : Star Semi-amplitude in km/s
        ecc : Eccentricity
        t14 : Total transit duration in hours for T14 transit
        t12 : Total transit duration in hours for T12 transit
        t23 : Total transit duration in hours for T23 transit
        opi : Periastron argument in radians. Defaults to 1.57
        stellar_teff : Stellar effective temperature in Kelvin. Defaults to 0
        ra: Right ascension in degrees. Defaults to 0
        dec: Declination in degrees. Defaults to 0
        a_Rs_ratio: Semi-major axis to stellar radius ratio. Defaults to 0
        projected_obliquity: Projected stellar obliquity in degrees. Defaults to 0
        inclination: Orbital inclination in degrees. Defaults to 0
        v_sini: Projected stellar rotational velocity in km/s. Defaults to 0
    """
    yaml_dict = {
        'name': target_id,
@@ -357,8 +324,10 @@ def insert_target_catalog(
        'period_days': float(period),
        't14_hours': float(t14),
        't12_hours': float(t12),
        't23_hours': float(t23),
        'Limit_Phase_T14': float(limph_T14),
        'Limit_Phase_T12': float(limph_T12),
        'Limit_Phase_T23': float(limph_T23),
        'kp_km_s': float(kp),
        'ks_km_s': float(ks),
        'v_system_km_s': float(vsys),
@@ -371,6 +340,7 @@ def insert_target_catalog(
        'inclination_deg': float(inclination),
        'v_sini_km_s': float(v_sini),
    }

    os.system("mkdir -p " + str(Path(path_target, target_id, "Models")))
    os.system("mkdir -p " + str(Path(path_target, target_id, "Star_Spectrum")))
    os.system("mkdir -p " + str(Path(path_target, target_id, "Retrievals")))
+34 −23
Original line number Diff line number Diff line
@@ -82,8 +82,14 @@ class Frame_Gofio:
                )
            except Exception as e:
                nights = ""
            self.target_name, self.target_radius, self.target_mass, self.target_gravity, self.target_t_eq, self.target_stellar_radius, self.target_stellar_mass, self.target_p0, self.target_hjd0, self.target_period, self.target_vsys, self.target_limph, self.target_kp, self.target_ecc, self.target_opi, self.target_stellar_teff, self.target_ra, self.target_dec, self.target_a_Rs_ratio, self.target_projected_obliquity, self.target_inclination, self.target_v_sini, self.target_limph_T12, self.target_t14_hours, self.target_t12_hours = DataInterface.get_target_info(
                self.path_target, target_list[0])
            (
                self.target_name, self.target_radius, self.target_mass, self.target_gravity, self.target_t_eq, self.target_stellar_radius, self.target_stellar_mass,
                self.target_p0, self.target_hjd0, self.target_period, self.target_vsys, self.target_limph, self.target_kp, self.target_ecc, self.target_opi,
                self.target_stellar_teff, self.target_ra, self.target_dec, self.target_a_Rs_ratio, self.target_projected_obliquity, self.target_inclination,
                self.target_v_sini, self.target_limph_T12, self.target_limph_T23, self.target_t14_hours, self.target_t12_hours, self.target_t23_hours
            ) = DataInterface.get_target_info(
                self.path_target, target_list[0]
            )
        else:
            nights = ""
        # nights
@@ -107,11 +113,6 @@ class Frame_Gofio:
        self.mass_DB = tk.Entry(master=self.tab_gofio, width=10)
        self.mass_DB.grid(column=5, row=0)
        #
        self.label = tk.Label(master=self.tab_gofio, text=r'T14 [hours]: ', font=('Sans', '9', 'bold'))
        self.label.grid(column=6, row=0, sticky=tk.W, )
        self.T14 = tk.Entry(master=self.tab_gofio, width=10)
        self.T14.grid(column=7, row=0)
        #
        self.label = tk.Label(master=self.tab_gofio, text=r'T Eq [K]: ', font=('Sans', '9', 'bold'))
        self.label.grid(column=8, row=0, sticky=tk.W, )
        self.t_eq_DB = tk.Entry(master=self.tab_gofio, width=10)
@@ -443,8 +444,6 @@ class Frame_Gofio:

            "Mass [M_J]:": "Planetary mass in Jupiter masses. Used to calculate surface gravity and atmospheric scale height.",

            "T14 [hours]:": "Total transit duration in hours, from first to fourth contact. Used to calculate the limb parameter and identify in-transit observations.",

            "T Eq [K]:": "Planetary equilibrium temperature in Kelvin. Calculated from stellar properties and orbital parameters, used in atmospheric modeling.",

            "Stellar Radius [R_S]:": "Host star radius in solar radii. Used to calculate transit depth and planetary parameters.",
@@ -1170,8 +1169,18 @@ class Frame_Gofio:
            )
        except:
            nights = ""
        self.target_name, self.target_radius, self.target_mass, self.target_gravity, self.target_t_eq, self.target_stellar_radius, self.target_stellar_mass, self.target_p0, self.target_hjd0, self.target_period, self.target_vsys, self.target_limph, self.target_kp, self.target_ecc, self.target_opi, self.target_stellar_teff, self.target_ra, self.target_dec, self.target_a_Rs_ratio, self.target_projected_obliquity, self.target_inclination, self.target_v_sini, self.target_limph_T12, self.target_t14_hours, self.target_t12_hours = DataInterface.get_target_info(
            self.path_target, target_id)
        (
            self.target_name, self.target_radius, self.target_mass, self.target_gravity, self.target_t_eq,
            self.target_stellar_radius, self.target_stellar_mass,
            self.target_p0, self.target_hjd0, self.target_period, self.target_vsys, self.target_limph, self.target_kp,
            self.target_ecc, self.target_opi,
            self.target_stellar_teff, self.target_ra, self.target_dec, self.target_a_Rs_ratio,
            self.target_projected_obliquity, self.target_inclination,
            self.target_v_sini, self.target_limph_T12, self.target_limph_T23, self.target_t14_hours,
            self.target_t12_hours, self.target_t23_hours
        ) = DataInterface.get_target_info(
            self.path_target, target_id
        )
        self.night.delete("1.0", tk.END)
        self.night.insert(tk.END, nights)

@@ -2005,24 +2014,24 @@ class Frame_Gofio:
                    (86400 * period) ** (1 / 3) * (mass_st_sun * Msun + mass_pl_jup_min * MJ) ** (2 / 3)
            )) / 1e3
            kp = ((mass_st_sun * Msun * ks) / (mass_pl_jup_min * MJ))
            gravity = phys_const.G * (mass_pl_jup * phys_const.m_jup) / np.power(radius_pl_jup * phys_const.r_jup_mean,
                                                                                 2)
            t14_hours_input = float(self.T14.get())
            gravity = phys_const.G * (mass_pl_jup * phys_const.m_jup) / np.power(radius_pl_jup * phys_const.r_jup_mean,2)
            phase_dict = DataInterface.compute_transit_durations(
                period, float(a_Rs_ratio),
                (radius_pl_jup * phys_const.r_jup_mean) / (float(radius_st_sun) * phys_const.r_sun),
                float(inclination), ecc=float(ecc), omega=float(opi), t14_def=t14_hours_input
                float(inclination), ecc=float(ecc), omega=float(opi)
            )
            limph_T14 = phase_dict["limph_T14"]
            limph_T12 = phase_dict["limph_T12"]
            limph_T23 = phase_dict["limph_T23"]
            t14_hours = phase_dict["T14_hours"]
            t12_hours = phase_dict["T12_hours"]
            t23_hours = phase_dict["T23_hours"]

            DataInterface.insert_target_catalog(
                self.path_target, target, str(radius_pl_jup), str(mass_pl_jup), str(gravity), str(T_eq),
                str(radius_st_sun), str(mass_st_sun),
                str(P0), str(hjd0), str(period), str(vsys), str(limph_T14), str(limph_T12),
                str(kp), str(ks), str(ecc), str(t14_hours), str(t12_hours),
                str(P0), str(hjd0), str(period), str(vsys), str(limph_T14), str(limph_T12), str(limph_T23),
                str(kp), str(ks), str(ecc), str(t14_hours), str(t12_hours), str(t23_hours),
                str(opi), str(stellar_teff), rad_mode,
                str(ra), str(dec),
                a_Rs_ratio=str(a_Rs_ratio),
@@ -2072,12 +2081,14 @@ class Frame_Gofio:
        if self.global_exc == 0:
            return
        target_id = self.chosen_target_var_DB.get()
        (target_name, target_radius, target_mass, target_gravity, target_t_eq, target_stellar_radius,
        (
            target_name, target_radius, target_mass, target_gravity, target_t_eq, target_stellar_radius,
            target_stellar_mass, target_p0, target_hjd0,
            target_period, target_vsys, target_limph, target_kp, target_ecc, target_opi, target_stellar_teff, target_ra,
            target_dec,
            target_a_Rs_ratio, target_projected_obliquity, target_inclination,
         target_v_sini, target_limph_T12, target_t14_hours, target_t12_hours) = DataInterface.get_target_info(self.path_target, target_id)
            target_v_sini, target_limph_T12, target_limph_T23, target_t14_hours, target_t12_hours, target_t23_hours
         ) = DataInterface.get_target_info(self.path_target, target_id)
        self.radius_DB_up.delete(0, tk.END)
        self.radius_DB_up.insert(tk.END, target_radius)
        self.mass_DB_up.delete(0, tk.END)