Esempio n. 1
0
def Pop_Visual(Tract_lat, Tract_lon, Tractx, Tracty, Tract_pop, Tract_area):
    """Import the population data and visualize it as a heatmap
    """
    Base = bm.BaseMapSet(dt.Type1, dt.llon, dt.rlon, dt.llat, dt.rlat)

    Base.scatter(Tract_lon,
                 Tract_lat,
                 latlon=True,
                 c=np.log10(Tract_pop),
                 s=Tract_area * 30,
                 cmap='Reds',
                 alpha=0.5)

    plt.colorbar(label=r'$\log_{10}({\rm population})$', shrink=0.6)

    for a in [100, 300, 500]:
        plt.scatter([], [],
                    c='k',
                    alpha=0.5,
                    s=a,
                    label=str(a) + '*0.03 mi$^2$')

    plt.legend(scatterpoints=1,
               frameon=False,
               labelspacing=1,
               loc='upper left')
    def drawlocation(self, Type, llon, rlon, llat, rlat):
        """Scatter the facility of the infrastructure system
        """
        bm.BaseMapSet(Type, llon, rlon, llat, rlat)

        plt.scatter(self.demandx,
                    self.demandy,
                    100,
                    self.color,
                    marker='o',
                    label=self.demandname)

        plt.scatter(self.tranx,
                    self.trany,
                    200,
                    self.color,
                    marker='*',
                    label=self.tranname)

        plt.scatter(self.supplyx,
                    self.supplyy,
                    400,
                    self.color,
                    marker='+',
                    label=self.supplyname)

        plt.legend(bbox_to_anchor=(1, 1),
                   loc='upper left',
                   ncol=1,
                   fontsize=25)
Esempio n. 3
0
 def scatternetwork(self, Type1, llon, rlon, llat, rlat):
     """Scatter the facility on the basemap
     """
     bm.BaseMapSet(Type1, llon, rlon, llat, rlat)
     
     plt.scatter(self.Geoloc[0:self.supplynum, 1], self.Geoloc[0:self.supplynum, 0], 400, self.color, marker = '+', label = self.supplyname)
     plt.scatter(self.Geoloc[self.supplynum:, 1], self.Geoloc[self.supplynum:, 0], 100, self.color, marker = 'o', label = self.demandname)
     
     plt.legend(bbox_to_anchor=(1, 1), loc='upper left', ncol=1, fontsize = 25, frameon = 0)
     
     plt.show()
Esempio n. 4
0
 def plotnetwork(self, Type1, llon, rlon, llat, rlat):
     """Plot the figure of the networks
     """
     bm.BaseMapSet(Type1, llon, rlon, llat, rlat)
     
     plt.scatter(self.Geoloc[0:self.supplynum, 1], self.Geoloc[0:self.supplynum, 0], 400, self.color, marker = '+', label = self.supplyname)
     plt.scatter(self.Geoloc[self.supplynum:, 1], self.Geoloc[self.supplynum:, 0], 100, self.color, marker = 'o', label = self.demandname)
     
     for i in range(len(self.adjmatrix)):
         for j in range(len(self.adjmatrix)):
             if(self.adjmatrix[i, j] == 1):
                 plt.plot([self.Geoloc[i, 1], self.Geoloc[j, 1]], [self.Geoloc[i, 0], self.Geoloc[j, 0]], 'black', lw = 1)
 
     plt.legend(bbox_to_anchor=(1, 1), loc='upper left', ncol=1, fontsize = 25, frameon = 0)
    def drawnetwork(self, Type, llon, rlon, llat, rlat):
        """Draw the network of the infrastructure system on the Basemap
        """
        bm.BaseMapSet(Type, llon, rlon, llat, rlat)

        plt.scatter(self.demandx,
                    self.demandy,
                    100,
                    self.color,
                    marker='o',
                    label=self.demandname)

        plt.scatter(self.tranx,
                    self.trany,
                    200,
                    self.color,
                    marker='*',
                    label=self.tranname)

        plt.scatter(self.supplyx,
                    self.supplyy,
                    400,
                    self.color,
                    marker='+',
                    label=self.supplyname)

        for i in range(len(self.Adjmatrix)):
            for j in range(len(self.Adjmatrix)):
                if (self.Adjmatrix[i, j] == 1):
                    plt.plot([self.x[i], self.x[j]], [self.y[i], self.y[j]],
                             'black',
                             lw=1)

        plt.legend(bbox_to_anchor=(1, 1),
                   loc='upper left',
                   ncol=1,
                   fontsize=25,
                   frameon=0)
    Network.cost = Sum_Cost


WN, WE = read(dt.WNpath, dt.WEpath)
PN, PE = read(dt.PNpath, dt.PEpath)
GN, GE = read(dt.GNpath, dt.GEpath)

Wlat, Wlon, WType, Wnum, Wedge = latlontypenumedge(WN, WE, dt.watername1,
                                                   dt.watername2)
Plat, Plon, PType, Pnum, Pedge = latlontypenumedge(PN, PE, dt.powername1,
                                                   dt.powername2)
Glat, Glon, GType, Gnum, Gedge = latlontypenumedge(GN, GE, dt.gasname1,
                                                   dt.gasname2)

plt.figure(figsize=(20, 12))
Base = bm.BaseMapSet(dt.Type1, dt.llon, dt.rlon, dt.llat, dt.rlat)
WX, WY = latlon2XY(Wlat, Wlon, Base)
PX, PY = latlon2XY(Plat, Plon, Base)
GX, GY = latlon2XY(Glat, Glon, Base)

Wsupply, Wtransmission, Wdemand = supplytrandemandnum(WType, dt.water1para,
                                                      Wnum)
Psupply, Ptransmission, Pdemand = supplytrandemandnum(PType, dt.power1para,
                                                      Pnum)
Gsupply, Gtransmission, Gdemand = supplytrandemandnum(GType, dt.gas1para, Gnum)

Shelby_Water = network(dt.water0para, Geox, Geoy)
Shelby_Power = network(dt.power0para, Geox, Geoy)
Shelby_Gas = network(dt.gas0para, Geox, Geoy)

Shelby_Water.x, Shelby_Water.y, Shelby_Water.Type = WX, WY, WType