コード例 #1
0
    def setup(self):

        self.img = np.asanyarray(Image.open("moonmap_tiny.png").convert("L"))
        self.craters = mkin.ReadCombinedCraterCSV(dropfeatures=True)
        cx, cy = mkin.coord2pix(self.craters["Long"].as_matrix(),
                                self.craters["Lat"].as_matrix(),
                                [-180, 180, -90, 90],
                                [self.img.shape[1], self.img.shape[0]])
        self.craters["x"] = cx
        self.craters["y"] = cy
        self.craters["Diameter (pix)"] = \
            self.craters["Diameter (km)"]*mkin.km2pix(self.img.shape[0], 180)
        self.craters.drop(np.where(self.craters["Diameter (pix)"] < 15.)[0],
                          inplace=True)
        self.craters.reset_index(inplace=True)

        self.img2 = np.zeros([200, 200])
        crat_x_list = np.array([100, 50, 2, 4, 167, 72, 198, 1])
        crat_y_list = np.array([100, 50, 1, 191, 3, 199, 198, 199])
        self.craters2 = pd.DataFrame([crat_x_list,
                                      crat_y_list]).T.rename(columns={
                                          0: "x",
                                          1: "y"
                                      })

        for i in range(len(crat_x_list)):
            self.img2[crat_y_list[i],
                      crat_x_list[i]] += 1  # add one at crater location
コード例 #2
0
    def test_pctoortho(self):

        imgo, imgwshp, offset = mkin.WarpImagePad(self.img,
                                                  self.iproj,
                                                  self.iextent,
                                                  self.oproj,
                                                  self.oextent,
                                                  origin="upper",
                                                  rgcoeff=1.2,
                                                  fillbg="black")

        ctr_xy = mkin.WarpCraterLoc(self.craters,
                                    self.geoproj,
                                    self.oproj,
                                    self.oextent,
                                    imgwshp,
                                    llbd=None,
                                    origin="upper")

        ctr_xy.loc[:, "x"] += offset[0]
        ctr_xy.loc[:, "y"] += offset[1]

        Cd = 1.
        pxperkm = mkin.km2pix(imgo.size[1], self.llbd[3] - self.llbd[2], \
                            dc=Cd, a=1737.4)
        ctr_xy["Diameter (pix)"] = ctr_xy["Diameter (km)"] * pxperkm

        imgo2, ctr_xy2 = mkin.PlateCarree_to_Orthographic(self.img,
                                                          None,
                                                          self.llbd,
                                                          self.craters,
                                                          iglobe=self.iglobe,
                                                          ctr_sub=True,
                                                          origin="upper",
                                                          rgcoeff=1.2,
                                                          dontsave=True,
                                                          slivercut=0.)

        imgo = np.asanyarray(imgo)
        imgo2 = np.asanyarray(imgo2)

        self.assertTrue(
            np.all(
                np.isclose(imgo.ravel(), imgo2.ravel(), rtol=1e-6,
                           atol=1e-10)))
        self.assertTrue(ctr_xy.equals(ctr_xy2))
コード例 #3
0
 def test_km2pix(self):
     mykmppix = 1500. / (np.pi * 1737.4) * 0.5
     kmppix = mkin.km2pix(1500., 180., dc=0.5, a=1737.4)
     assert np.isclose(mykmppix, kmppix, rtol=1e-7, atol=1e-10)