Exemplo n.º 1
0
def drop_outlayers_by_borovicka(pixtab_df, plano, diff=1):

    X_MIN = 250
    X_MAX = 1250
    Y_MIN = 0
    Y_MAX = 950
    MAX_RADIO = 500
    RADIO_STEPS = 2000
    query_str = "{}<=x<={} and {}<=y<={}".format(X_MIN, X_MAX, Y_MIN, Y_MAX)
    data = pixtab_df.dropna(thresh=7).query(query_str)

    #     pbar = tqdm(total=len(data.x.values), desc="Droping Outlayers")
    new_df_indx = []
    for indx in PBarATP(data.index, name="Droping Outlayers"):
        #     for indx in data.index:
        x = data.at[indx, "x"]
        y = data.at[indx, "y"]
        alt = data.at[indx, "alt"]
        if np.abs(plano(x, y) - alt) < diff:
            new_df_indx.append(indx)


#         pbar.update()
#     pbar.close()
    return data.loc[new_df_indx]
Exemplo n.º 2
0
 def _merge_dataframe(self, df_pixtab, df_dat):
     df_header = ["x", "y", "alt", "az", "alt_err", "az_err", "sample_size"]
     df_data = []
     M_alt, M_az = self._extract_3dmatrix(df_dat)
     print("Reduciendo y fusionando nuevos datos...")
     df = df_pixtab
     for x,y,alt,az,alt_err,az_err,samsize in PBarATP( zip(df.x.values,
                                                     df.y.values,
                                                     df.alt.values,
                                                     df.az.values,
                                                     df.alt_err.values,
                                                     df.az_err.values,
                                                     df.sample_size.values),
                                                     total=len(df.x.values),
                                                             name="Pixels"):
         m_alt = M_alt[y][x]
         m_az = M_az[y][x]
         if len(m_alt) and not samsize:
             pixel_info = self._get_new_pixel(x, y, m_alt, m_az)
             df_data.append([x,y,alt,az,alt_err,az_err,samsize])
         elif len(m_alt) and samsize:
             pixel_info = self._get_merged_pixel(x, y, alt, az, alt_err, az_err,
                                                     samsize, m_alt, m_az, samsize)
             df_data.append([x,y,alt,az,alt_err,az_err,samsize])
         elif not len(m_alt):
             df_data.append([x,y,alt,az,alt_err,az_err,samsize])
     df_merged = pd.DataFrame(df_data, columns= df_header)
     time.sleep(1)
     print("Done")
     return df_merged
Exemplo n.º 3
0
 def catpixtab2dat(pixtab):
     new_df_header = ["xcentroid", "ycentroid", "alt", "az", "star_name"]
     new_df_data = []
     old_df = pixtab.dropna()
     for indx in PBarATP(old_df.index, name="Interpolation"):
         x = old_df.at[indx, "x"]
         y = old_df.at[indx, "y"]
         alt = old_df.at[indx, "star_alt"]
         az = old_df.at[indx, "star_az"]
         star_name = old_df.at[indx, "star_name"]
         new_df_data.append([x, y, alt, az, star_name])
     df = pd.DataFrame(new_df_data, columns=new_df_header)
     return df
Exemplo n.º 4
0
 def create(self):
     print("\nCreando vista previa de pixeles")
     # self._image_alt = imageio.imread(self.PATH_MASK)
     # self._image_az = imageio.imread(self.PATH_MASK)
     self._image_preview = imageio.imread(self.PATH_MASK)
     for indx in PBarATP(self._pixels.index, name="Pixels"):
         x = self._pixels.at[indx, 'x']
         y = self._pixels.at[indx, 'y']
         # alt = self._pixels.at[indx, "alt"]
         # az = self._pixels.at[indx, "az"]
         # self._coloring_pixels_alt(x, y, alt)
         # self._coloring_pixels_az(x, y, az)
         self._coloring_pixels_preview(x, y)
     print("Exito!")
 def create(self):
     print("\nCreando vista previa de pixeles")
     self._image_alt = imageio.imread(self.PATH_MASK)
     self._image_az = imageio.imread(self.PATH_MASK)
     # pbar = ProgressBarCounter(self._pixels.shape[0])
     for indx in PBarATP(self._pixels.index, name="Pixels"):
         x = self._pixels.at[indx,'x']
         y = self._pixels.at[indx,'y']
         alt = self._pixels.at[indx, "alt"]
         az = self._pixels.at[indx, "az"]
         self._coloring_pixels_alt(x, y, alt)
         self._coloring_pixels_az(x, y, az)
         # pbar.notify()
     print("Exito!")
 def _interpolate_df_data(self):
     Y_MIN = InterpolatorBorovicka.Y_MIN
     Y_MAX = InterpolatorBorovicka.Y_MAX
     X_MIN = InterpolatorBorovicka.X_MIN
     X_MAX = InterpolatorBorovicka.X_MAX
     x = np.arange(X_MIN, X_MAX)
     y = np.arange(Y_MIN, Y_MAX)
     X, Y = np.meshgrid(x, y)
     ALT = self.altura(X, Y)
     AZ = self.azimut(X, Y)
     for row_x, row_y, row_alt, row_az in PBarATP(zip(X,Y,ALT,AZ),
                                                 total=len(X),
                                                     name="Interpolation"):
         for x, y, alt, az in zip(row_x, row_y, row_alt, row_az):
             yield [int(x), int(y), alt, az]
Exemplo n.º 7
0
    def _gen_worker_args(self, df_pixtab, df_dat):
        m_alt, m_az = self._extract_3dmatrix(df_dat)
        print("\nReduciendo y fusionando nuevos datos...")
        df = df_pixtab
        for x,y,alt,az,alt_err,az_err,samsize in PBarATP( zip(df.x.values,
                                                        df.y.values,
                                                        df.alt.values,
                                                        df.az.values,
                                                        df.alt_err.values,
                                                        df.az_err.values,
                                                        df.sample_size.values),
                                                        total=len(df.x.values),
                                                                name="Pixels"):

            yield (x,y,alt,az,alt_err,az_err,samsize, m_alt[y][x], m_az[y][x])
Exemplo n.º 8
0
 def _extract_3dmatrix(self, df):
     total = df.shape[0]
     m_alt = self.create_empty_matrix(self.PIXTAB_Y_RESOLUTION,
                                                 self.PIXTAB_X_RESOLUTION)
     m_az = self.create_empty_matrix(self.PIXTAB_Y_RESOLUTION,
                                                 self.PIXTAB_X_RESOLUTION)
     print("\nTamaño de la nueva muestra: {}".format(total))
     print("Extrayendo altura y azimuth...")
     for x, y, alt, az in PBarATP(zip(df.xcentroid.values, df.ycentroid.values,
                                     df.alt.values, df.az.values),
                                                 total=len(df.alt.values),
                                                          name="New Data"):
         m_alt[y][x].append(alt)
         m_az[y][x].append(az)
     time.sleep(1)
     print("Done")
     return m_alt, m_az
    def _azimut_corrector(self, df):
        for x in PBarATP(range(self.X_MIN, self.X_MAX+1),
                                                    name="Correcting Azimut"):

            if x in range(self.X_MIN, int(self.X0)):
                col_data = df.query("xcentroid=={}".format(x))
                if len(col_data):
                    y_min = col_data.at[col_data.idxmin().az, "ycentroid"]
                    for indx in col_data.query("ycentroid<{}".format(y_min)).index:
                        df.at[indx, "az"] = 360 - col_data.at[indx, "az"]
                # pbar.update()
            elif x in range(int(self.X0), self.X_MAX+1):
                col_data = df.query("xcentroid=={}".format(x))
                if len(col_data):
                    y_min = col_data.at[np.abs(col_data.az - 180).idxmin(), "ycentroid"]
                    for indx in col_data.query("ycentroid<{}".format(y_min)).index:
                        df.at[indx, "az"] = 360 - col_data.at[indx, "az"]
        return df
Exemplo n.º 10
0
 def _gen_worker_args_read_catalog(self, path, alt_az_frame):
     with open(path, "r", encoding="utf-8") as file:
         for line in PBarATP(file, 9110, name="{}".format(path)):
             if line.replace("\n", "")[75:77] != "  ":
                 yield (line, alt_az_frame)
Exemplo n.º 11
0
 def _gen_worker_args(self, catalogue_df, df_pixtab, *args, **kwargs):
     for indx in PBarATP(catalogue_df.index, name="Objects"):
         yield (catalogue_df.loc[indx], df_pixtab)