Ejemplo n.º 1
0
def extinctionCorrectionApparentToTrue(mags, x_data, y_data, jd, platepar):
    """ Compute true magnitudes by applying extinction correction to apparent magnitudes. 
    
    Arguments:
        mags: [list] A list of apparent magnitudes.
        x_data: [list] A list of pixel columns.
        y_data: [list] A list of pixel rows.
        jd: [float] Julian date.
        platepar: [Platepar object]

    Return:
        corrected_mags: [list] A list of extinction corrected mangitudes.

    """

    ### Compute star elevations above the horizon (epoch of date, true) ###

    # Compute RA/Dec in J2000
    _, ra_data, dec_data, _ = xyToRaDecPP(len(x_data)*[jd2Date(jd)], x_data, y_data, len(x_data)*[1], \
        platepar, extinction_correction=False)

    # Compute elevation above the horizon
    elevation_data = []
    for ra, dec in zip(ra_data, dec_data):

        # Precess to epoch of date
        ra, dec = equatorialCoordPrecession(J2000_JD.days, jd, np.radians(ra),
                                            np.radians(dec))

        # Compute elevation
        _, elev = raDec2AltAz(np.degrees(ra), np.degrees(dec), jd,
                              platepar.lat, platepar.lon)

        if elev < 0:
            elev = 0

        elevation_data.append(elev)

    ### ###

    # Correct catalog magnitudes for extinction
    extinction_correction = atmosphericExtinctionCorrection(np.array(elevation_data), platepar.elev) \
        - atmosphericExtinctionCorrection(90, platepar.elev)
    corrected_mags = np.array(
        mags) - platepar.extinction_scale * extinction_correction

    return corrected_mags
Ejemplo n.º 2
0
def extinctionCorrectionTrueToApparent(catalog_mags, ra_data, dec_data, jd,
                                       platepar):
    """ Compute apparent magnitudes by applying extinction correction to catalog magnitudes. 
    
    Arguments:
        catalog_mags: [list] A list of catalog magnitudes.
        ra_data: [list] A list of catalog right ascensions (J2000) in degrees.
        dec_data: [list] A list of catalog declinations (J2000) in degrees.
        jd: [float] Julian date.
        platepar: [Platepar object]

    Return:
        corrected_catalog_mags: [list] Extinction corrected catalog magnitudes.

    """

    ### Compute star elevations above the horizon (epoch of date, true) ###

    # Compute elevation above the horizon
    elevation_data = []
    for ra, dec in zip(ra_data, dec_data):

        # Precess to epoch of date
        ra, dec = equatorialCoordPrecession(J2000_JD.days, jd, np.radians(ra),
                                            np.radians(dec))

        # Compute elevation
        _, elev = raDec2AltAz(np.degrees(ra), np.degrees(dec), jd,
                              platepar.lat, platepar.lon)

        if elev < 0:
            elev = 0

        elevation_data.append(elev)

    ### ###

    # Correct catalog magnitudes for extinction
    extinction_correction = atmosphericExtinctionCorrection(np.array(elevation_data), platepar.elev) \
        - atmosphericExtinctionCorrection(90, platepar.elev)
    corrected_catalog_mags = np.array(
        catalog_mags) + platepar.extinction_scale * extinction_correction

    return corrected_catalog_mags
Ejemplo n.º 3
0
def applyPlateparToCentroids(ff_name,
                             fps,
                             meteor_meas,
                             platepar,
                             add_calstatus=False):
    """ Given the meteor centroids and a platepar file, compute meteor astrometry and photometry (RA/Dec, 
        alt/az, mag).

    Arguments:
        ff_name: [str] Name of the FF file with the meteor.
        fps: [float] Frames per second of the video.
        meteor_meas: [list] A list of [calib_status, frame_n, x, y, ra, dec, azim, elev, inten, mag].
        platepar: [Platepar instance] Platepar which will be used for astrometry and photometry.

    Keyword arguments:
        add_calstatus: [bool] Add a column with calibration status at the beginning. False by default.

    Return:
        meteor_picks: [ndarray] A numpy 2D array of: [frames, X_data, Y_data, RA_data, dec_data, az_data, 
        alt_data, level_data, magnitudes]

    """

    meteor_meas = np.array(meteor_meas)

    # Add a line which is indicating the calibration status
    if add_calstatus:
        meteor_meas = np.c_[np.ones((meteor_meas.shape[0], 1)), meteor_meas]

    # Remove all entries where levels are equal to or smaller than 0, unless all are zero
    level_data = meteor_meas[:, 8]
    if np.any(level_data):
        meteor_meas = meteor_meas[level_data > 0, :]

    # Extract frame number, x, y, intensity
    frames = meteor_meas[:, 1]
    X_data = meteor_meas[:, 2]
    Y_data = meteor_meas[:, 3]
    level_data = meteor_meas[:, 8]

    # Get the beginning time of the FF file
    time_beg = filenameToDatetime(ff_name)

    # Calculate time data of every point
    time_data = []
    for frame_n in frames:
        t = time_beg + datetime.timedelta(seconds=frame_n / fps)
        time_data.append([
            t.year, t.month, t.day, t.hour, t.minute, t.second,
            int(t.microsecond / 1000)
        ])

    # Convert image cooredinates to RA and Dec, and do the photometry
    JD_data, RA_data, dec_data, magnitudes = xyToRaDecPP(np.array(time_data), X_data, Y_data, \
        level_data, platepar)

    # Compute azimuth and altitude of centroids
    az_data = np.zeros_like(RA_data)
    alt_data = np.zeros_like(RA_data)

    for i in range(len(az_data)):

        jd = JD_data[i]
        ra_tmp = RA_data[i]
        dec_tmp = dec_data[i]

        # Precess RA/Dec to epoch of date
        ra_tmp, dec_tmp = equatorialCoordPrecession(J2000_JD.days, jd, np.radians(ra_tmp), \
            np.radians(dec_tmp))

        # Alt/Az are apparent (in the epoch of date, corresponding to geographical azimuths)
        az_tmp, alt_tmp = raDec2AltAz(np.degrees(ra_tmp), np.degrees(dec_tmp),
                                      jd, platepar.lat, platepar.lon)

        az_data[i] = az_tmp
        alt_data[i] = alt_tmp

    # print(ff_name, cam_code, meteor_No, fps)
    # print(X_data, Y_data)
    # print(RA_data, dec_data)
    # print('------------------------------------------')

    # Construct the meteor measurements array
    meteor_picks = np.c_[frames, X_data, Y_data, RA_data, dec_data, az_data, alt_data, level_data, \
        magnitudes]

    return meteor_picks