Exemple #1
0
def meansqdist(x):
    # function to be minimized mean square of angular distance between measured
    # and predicted moon positions
    # vars = string array of parameters to vary in x
    # start with just varying cam.rot
    cam.pr0 = x[0]
    cam.cy = x[1]
    cam.cx = x[2]
    cam.rot = x[3]
    cam.beta = x[4]
    cam.azm = x[5]
    cam.c1 = x[6]
    cam.c2 = x[7]
    cam.c3 = (0.5 - (cam.c1 * pi2 + cam.c2 * pi2**3)) / pi2**5
    cam.azizen()
    ix = (dfref.xmoon + 0.5).astype(int)
    iy = (dfref.ymoon + 0.5).astype(int)
    otheta = cam.theta0[iy, ix]
    ophi = cam.phi0[iy, ix]
    ptheta = []
    pphi = []
    for edate in dfref.ephemDate:
        obs.date = edate
        moon.compute(obs)
        ptheta.append(np.pi / 2. - moon.alt)
        pphi.append((moon.az - np.pi) % (2 * np.pi))
    ptheta = np.array(ptheta)
    pphi = np.array(pphi)
    return np.mean(
        camcoord.great_circle_distance(otheta, ophi, ptheta, pphi)**2)
Exemple #2
0
def dist(x):
    # function returns residuals to be
    # minimized by least-squares angular distance between measured
    # and predicted moon positions
    # vars = string array of parameters to vary in x
    # start with just varying cam.rot
    cam.pr0 = x[0]
    cam.cy = x[1]
    cam.cx = x[2]
    cam.rot = x[3]
    cam.beta = x[4]
    cam.azm = x[5]
    cam.c1 = x[6]
    cam.c2 = x[7]
    if constrained_c3:
        cam.c3 = (0.5 - (cam.c1 * pi2 + cam.c2 * pi2**3)) / pi2**5
    else:
        cam.c3 = x[8]
    cam.azizen()
    ix = (dfref.xmoon + 0.5).astype(int)
    iy = (dfref.ymoon + 0.5).astype(int)
    otheta = cam.theta0[iy, ix]
    ophi = cam.phi0[iy, ix]
    try:
        exist = (len(ptheta) == len(otheta))
    except:
        exist = False
    if not exist:
        ptheta = []
        pphi = []
        for edate in dfref.ephemDate:
            obs.date = edate
            moon.compute(obs)
            ptheta.append(np.pi / 2. - moon.alt)
            pphi.append((moon.az - np.pi) % (2 * np.pi))
        ptheta = np.array(ptheta)
        pphi = np.array(pphi)
    return camcoord.great_circle_distance(otheta, ophi, ptheta, pphi)
        try:
            camopt = camcoord.camera(cameraID,
                                     camera_cal_file=camera_cal_file_optimized)
        except:
            plotopt = False
    # calculate azi and zen for each pixel, to optimize vary camera parameters
    # rot,cx,cy,nr0,beta,azm,c1,c2,c3 and recalculate.
        cam.azizen()
        if plotopt:
            camopt.azizen()
        # obs is an ephem observer object
        obs = ephem.Observer()
        # abort if camopt cam is more than 10 m from opt

        if plotopt and camcoord.great_circle_distance(
                np.pi / 2. - np.deg2rad(cam.lat), np.deg2rad(
                    cam.lon), np.pi / 2. - np.deg2rad(camopt.lat),
                np.deg2rad(camopt.lon)) > (10. / ephem.earth_radius):
            print("lat lon should agree", cam.lat, cam.lon, camopt.lat,
                  camopt.lon)
            raise RuntimeError("camera moved")
        # lat, lon are the only parameters in config file specified in deg.
        # ephem and numpy use radian
        obs.lat = np.deg2rad(cam.lat)
        obs.lon = np.deg2rad(cam.lon)
        # moon is an ephem moon object
        moon = ephem.Moon()
        fig, axs = plt.subplots(2,
                                1,
                                sharex=True,
                                sharey=True,
                                gridspec_kw={'hspace': 0.0})
Exemple #4
0
        try:
            camopt = camcoord.camera(cameraID,
                                     camera_cal_file=camera_cal_file_optimized)
        except:
            plotopt = False
    # calculate azi and zen for each pixel, to optimize vary camera parameters
    # rot,cx,cy,nr0,beta,azm,c1,c2,c3 and recalculate.
        cam.azizen()
        if plotopt:
            camopt.azizen()
        # obs is an ephem observer object
        obs = ephem.Observer()
        # abort if camopt cam is more than 10 m from opt

        if plotopt and camcoord.great_circle_distance(
                np.pi / 2. - np.deg2rad(cam.lat), np.deg2rad(
                    cam.lon), np.pi / 2. - np.deg2rad(camopt.lat),
                np.deg2rad(camopt.lon)) > (10. / ephem.earth_radius):
            print("lat lon should agree", cam.lat, cam.lon, camopt.lat,
                  camopt.lon)
            raise RuntimeError("camera moved")
        # lat, lon are the only parameters in config file specified in deg.
        # ephem and numpy use radian
        obs.lat = np.deg2rad(cam.lat)
        obs.lon = np.deg2rad(cam.lon)
        # moon is an ephem moon object
        moon = ephem.Moon()
        #
        # read moon position data from find_moon output .csv file
        moonobsfile = Path(outpath, cam.camID + moon_obs_ext)
        # read into pandas DataFrame
        dfref = pd.read_csv(moonobsfile, index_col=0)
Exemple #5
0
     plotopt=True
     try:
         camopt=camcoord.camera(cameraID,camera_cal_file=camera_cal_file_optimized)
     except:
         plotopt=False
 # calculate azi and zen for each pixel, to optimize vary camera parameters
 # rot,cx,cy,nr0,beta,azm,c1,c2,c3 and recalculate.
     cam.azizen()
     if plotopt:
         camopt.azizen()
     # obs is an ephem observer object
     obs = ephem.Observer();
 # abort if camopt cam is more than 10 m from opt
 
     if plotopt and camcoord.great_circle_distance(np.pi/2.-np.deg2rad(cam.lat),
                                           np.deg2rad(cam.lon),
                                           np.pi/2.-np.deg2rad(camopt.lat),
                                           np.deg2rad(camopt.lon)) > (
                                               10./ephem.earth_radius):
         print("lat lon should agree",cam.lat, cam.lon,camopt.lat,camopt.lon)
         raise RuntimeError("camera moved")
     # lat, lon are the only parameters in config file specified in deg.
     # ephem and numpy use radian
     obs.lat = np.deg2rad(cam.lat)
     obs.lon = np.deg2rad(cam.lon)
     # moon is an ephem moon object
     moon=ephem.Moon()
 #
 # read moon position data from find_moon output .csv files
     moonobsdir=Path(outpath,cam.camID)
     moonobsfiles=sorted(moonobsdir.glob("*"+moon_obs_ext))
     res=[]