Example #1
0
def exportcsv(dataType):

    c = setting()
    l = logger('exportData')
    databasePath = c.get('parser', 'db_path')
    db = dbConnection(databasePath, l)
    try:
        filename = c.get('exportcsv',
                         'output_path') + '/export-data-' + dataType + '.csv'
        file = open(filename, "w")
        writer = csv.writer(file,
                            delimiter=',',
                            quotechar='"',
                            quoting=csv.QUOTE_ALL)
        data = []
        if 'station' == dataType:
            headers = db.getAllStationInfoHeaders()
            data = db.getAllStationInfo()
        elif 'train' == dataType:
            headers = db.getAllTrainInfoHeaders()
            data = db.getAllTrainInfo()
        # Writing the values
        writer.writerow(list(headers))
        for row in data:
            writer.writerow(list(row))
        file.close()

    except (IOError, Exception) as e:
        print e
Example #2
0
def exportcsv(dataType):

    c = setting()
    l = logger('exportData')
    databasePath = c.get('parser', 'db_path')
    db = dbConnection(databasePath, l)
    try:
        filename= c.get ('exportcsv', 'output_path') + '/export-data-' + dataType + '.csv'
        file  = open(filename, "w")
        writer = csv.writer(file, delimiter=',', quotechar='"', quoting=csv.QUOTE_ALL)
        data = []
        if 'station' == dataType:
            headers = db.getAllStationInfoHeaders()
            data = db.getAllStationInfo()
        elif 'train' == dataType:
            headers = db.getAllTrainInfoHeaders()
            data = db.getAllTrainInfo()
        # Writing the values
        writer.writerow(list(headers))
        for row in data:
            writer.writerow(list(row))
        file.close()

    except (IOError, Exception) as e:
            print e
Example #3
0
 def __init__(self, databasePath, systemType):
     self.systemType = systemType
     self.logging = logger(self.systemType)
     self.databasePath = databasePath
     self.db = dbConnection(self.databasePath, self.logging)
     self.writer = publish(self.logging)
     self.__cfg = setting()
     self.__ticketPrint = False
Example #4
0
 def __init__(self):
     self.c = setting()
     self.logging = logger('export')
     databasePath = self.c.get('parser', 'db_path')
     self.db = dbConnection(databasePath, self.logging)
     self.writeCsv()
     dataClean = int(self.c.get('exportcsv', 'data_clean'))
     if 1 == int(dataClean):
         self.db.deleteAllTicketDetails()
Example #5
0
 def __init__(self):
     self.c = setting()
     self.logging = logger('export')
     databasePath = self.c.get('parser', 'db_path')
     self.db = dbConnection(databasePath, self.logging)
     self.writeCsv()
     dataClean = int(self.c.get('exportcsv', 'data_clean'))
     if 1 == int(dataClean):
         self.db.deleteAllTicketDetails()
Example #6
0
    def setUp(self):
        '''初始化里面主要做的是获取接口需要的参数,比如:IP、路径、端口号、头文件、方法、数据库连接等数据'''
        # 通过继承调用logger用于在console打印日志
        self.logger = logger(consoleLevel=logging.DEBUG,
                             logFile=LogFilePath,
                             fileLevel=logging.DEBUG)
        self.logger.info('从ini,excel文件中开始读取数据')

        self.host = CommonMethod().Get_Host()
        self.headers = CommonMethod().Get_Headers()
        self.DataType = CommonMethod().Get_DataType()

        if CommonMethod().Get_Token() == "":
            self.headers = CommonMethod().Get_Headers()
        else:
            a = eval(CommonMethod().Get_Headers())
            a["X-Auth-Token"] = CommonMethod().Get_Token()
            self.headers = json.dumps(a)
Example #7
0
def importcsv(dataType):

    c = setting()
    l = logger('exportData')
    databasePath = c.get('parser', 'db_path')
    db = dbConnection(databasePath, l)
    try:
        filename = c.get('exportcsv',
                         'output_path') + '/import-data-' + dataType + '.csv'
        reader = csv.reader(open(filename, 'r'), delimiter=',')

        if 'station' == dataType:
            tablename = 'stationinfo'
        elif 'train' == dataType:
            tablename = 'traininfo'

        rowno = 1
        fields = ''
        for data in reader:
            if 1 == rowno:
                # Validating colums
                validColumns(dataType, data)
                # Drop the schema of table
                try:
                    db.cursor.execute('drop table ' + tablename)
                except Exception as e:
                    pass
                # create the table
                sql = createTable(tablename, data)
                db.cursor.execute(sql)
                # build the insert query
                sql = insertTable(tablename, data)
            else:
                # execute the  insert query
                try:
                    db.cursor.execute(sql, data)
                    db.connection.commit()
                except (IOError, Exception) as e:
                    print 'Error: Inserting row :' + e
            rowno += 1
        #db.connection.commit()
    except (IOError, Exception) as e:
        print e
Example #8
0
def importcsv(dataType):

    c = setting()
    l = logger('exportData')
    databasePath = c.get('parser', 'db_path')
    db = dbConnection(databasePath, l)
    try:
        filename= c.get ('exportcsv', 'output_path') + '/import-data-' + dataType + '.csv'
        reader = csv.reader(open(filename, 'r'), delimiter=',')

        if 'station' == dataType:
            tablename = 'stationinfo'
        elif 'train' == dataType:
            tablename = 'traininfo'

        rowno = 1
        fields = ''
        for data in reader:
            if 1 == rowno:
                # Validating colums
                validColumns(dataType, data)
                # Drop the schema of table
                try:
                    db.cursor.execute('drop table ' + tablename)
                except Exception as e:
                    pass
                # create the table
                sql = createTable(tablename, data)
                db.cursor.execute(sql)
                # build the insert query
                sql = insertTable(tablename, data)
            else:
                # execute the  insert query
                try:
                    db.cursor.execute(sql, data)
                    db.connection.commit()
                except (IOError, Exception) as e:
                    print 'Error: Inserting row :' + e
            rowno += 1
        #db.connection.commit()
    except (IOError, Exception) as e:
            print e
Example #9
0
# -*- coding: gb18030 -*-
# -*- coding: utf-8 -*-

from selenium.webdriver.common.by import By
from public.po.base_view import BaseView
import logging
from log.log import logger
from public.common.desired_caps import desired
from public.common.do_excel import ReadExcel
# from public.po.login_page import LoginPage
from public.common.adb_shell import AdbShell
from time import sleep

# 日志类的实例化
logger = logger(__name__, Cmdlevel=logging.INFO, Filelevel=logging.INFO)


class NewOderPage(BaseView):
    """
    新建订单页面的所有的xpth、元素
    """
    # 订单管理
    oder_management_xpath = "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.View/android.view.View/android.view.View/android.view.View/android.view.View[3]/android.view.View"
    # 选择门店
    choose_shop_xapth = "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.View/android.view.View/android.view.View/android.view.View/android.view.View[1]/android.view.View[1]"
    # 测试门店第二个门店
    test_shop_xpath = "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.View/android.view.View/android.view.View/android.view.View/android.view.View/android.view.View/android.view.View[3]"
    # 新建订单按钮
    new_oder_btn_xpath = "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.View/android.view.View/android.view.View/android.view.View/android.widget.Button"
    # 选择房间
    choose_room_xpath = "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.View/android.view.View/android.view.View/android.view.View/android.view.View[2]/android.widget.ScrollView/android.view.View[1]/android.view.View[1]"
Example #10
0
def main(argv=None):
    """
    This example:
    1) defines a coordinate converter based on Mars ellipsoid characteristics
    2) loads MOLA128 radius data
    3) defines a dummy simulator using the pre-defined coordinate converter and
       the MOLA128 DEM
    4)
        a) loads the ancillary part of a PDS Italian EDR product
        b) simulates the radargram using the orbit data (one frame every 26)
        c) saves the simulation and the image representing uncertain frames on disk
    5) loads the ancillary part of a CO-SHARPS raw product
        a) interpolates the geometric data in order to get the orbit information
           of one frame every 26
        b) simulates the radargram using the orbit data (one frame every 26)
        c) saves the simulation and the image representing uncertain frames on disk
    6) repeats the same steps using RDR PDS Italian data, also saving the RDR focused
       data on disk
    7) repeats the same steps using RDR PDS US data, also saving the RDR focused
       data on disk
    """

    lg = logger(verbose=True)

    # Mars ellipsoid characteristics
    cc = CoordinateConverter("Mars IAU 2000", 3396190., 3376200.)

    # the MOLA128 radius data are contained in a single ENVI file
    m = MOLA128(filename_base="/yourpath/r128")        # MOLA radius data
    m.read()

    # definition of a dummy RS simulator using the Mars coordinate converter and the MOLA128 DEM
    s = dRSsim(geom_obj=cc, dem_obj=m, n_processes=6)       # simulation parameters are contained in the dRSsim class

    # change fn_base with your OBS folder path+base file name (without suffixes)
    # EDR PDS
    fn_base = "/yourpath/e_1260201_001_ss19_700_a"
    d = EDR_PDS(dataset_name="edr1260201", filename_base=fn_base, logger=lg)
    d.load(mode="ancillary")
    d.generate_orbit_data(skip=26)
    od_pds_edr = d.orbit_data
    if od_pds_edr is not None:
        sim_image, uncert_image = s.simulate(od_pds_edr)
        envi.write("/yourpath/test_pds-edr_sim", sim_image)
        envi.write("/yourpath/test_pds-edr_sim_uncert", uncert_image)

    # EDR CO-SHARPS
    fn_base = "/yourpath/OBS_1260201000_1"
    d = EDR_COSHARPS(dataset_name="OBS_1260201000_1", filename_base=fn_base, logger=lg)
    d.load(mode="ancillary")
    d.generate_orbit_data(skip=26)
    od_cosharps_edr = d.orbit_data
    if od_cosharps_edr is not None:
        sim_image, uncert_image = s.simulate(od_cosharps_edr)
        envi.write("/yourpath/test_cosharps-edr_sim", sim_image)
        envi.write("/yourpath/test_cosharps-edr_sim_uncert", uncert_image)

    # RDR PDS
    fn_base = "/yourpath/r_1260201_001_ss19_700_a"
    d = RDR_PDS(dataset_name="rdr1260201", filename_base=fn_base, logger=lg)
    d.load()                        # note 1: d.data is np.complex64 for PDS RDR data
                                    # note 2: no "mode" is provided, as all data are contained in one unique file
    envi.write("/yourpath/test_pds_rdr_data", d.data)      # data is automatically converted into power. If complex output is needed, use the complex_output=True flag
    d.generate_orbit_data(skip=26)
    od_pds_rdr = d.orbit_data
    if od_pds_rdr is not None:
        sim_image, uncert_image = s.simulate(od_pds_rdr)
        envi.write("/yourpath/test_pds-rdr_sim", sim_image)
        envi.write("/yourpath/test_pds-rdr_sim-uncert", uncert_image)

    # RDR PDS US
    fn_base = "/yourpath/s_01260201"
    d = RDR_PDS_US(dataset_name="s_01260201", filename_base=fn_base, logger=lg)
    d.load(mode="full")
    envi.write("/yourpath/test_pds-us-rdr_data", d.data)

    d.generate_orbit_data()
    od_pds_us_rdr = d.orbit_data
    if od_pds_us_rdr is not None:
        sim_image, uncert_image = s.simulate(od_pds_us_rdr)
        envi.write("/yourpath/test_pds-us-rdr_sim", sim_image)
        envi.write("/yourpath/test_pds-us-rdr_sim_uncert", uncert_image)
Example #11
0
def main(argv=None):
    """
    This example:
    1) creates an instance of a SHARAD object
    2) defines a coordinate converter based on Mars ellipsoid characteristics
    3) loads MOLA128 radius data
    4) creates an object containing the parameters used in the focuser (that
       will be used also by the simulator)
    5) defines a square facets simulator using the pre-defined coordinate converter, the
       MOLA128 DEM and the parameter object
    6) loads a PDS Italian EDR product
    7) simulates the radargram using the orbit data and saves the result on disk
    8) creates some plots: simulation, first return positions, minimum ground distance
       of clutter contributions for each simulation sample
    9) focuses the data, saves the result on disk and plots the focused radargram

    Examples of how to read other data formats are commented at the end of the code.
    """

    MOLA128_FILENAME_BASE = "/yourpath/mola-radius-data"

    EDR_PDS_INPUT_FILENAME_BASE = "/yourpath/e_1260201_001_ss19_700_a"  # OBS folder path+base file name (without suffixes)
    EDR_PDS_INPUT_DATASET_NAME = "edr1260201"
    EDR_PDS_OUTPUT_SIM_FILENAME_BASE = "/yourpath/PDS-EDR-1260201_SIM"
    EDR_PDS_OUTPUT_FOC_FILENAME_BASE = "/yourpath/PDS-EDR-1260201_FOC"

    FRAME_START = 80000
    FRAME_END = 100000
    METERS_SKIP = 450
    FRAME_HALF_APERTURE = 128  # use 758 for "standard" focusing with presumming = 4
    SQUINT_ANGLE = 0

    lg = logger(verbose=True)

    # create SHARAD instrument instance
    i = SHARAD()

    # Mars ellipsoid characteristics
    cc = MARS_IAU2000()

    # the MOLA128 radius data are contained in a single ENVI file
    m = MOLA128(filename_base=MOLA128_FILENAME_BASE)  #mola_mars_data.hdr
    m.read()

    # definition of focuser and simulator parameters
    pars = FocuserParameters(frame_start=FRAME_START,
                             frame_end=FRAME_END,
                             meters_skip=METERS_SKIP,
                             frame_half_aperture=FRAME_HALF_APERTURE,
                             squint_angle=SQUINT_ANGLE)

    # definition of a square facets RS simulator using the Mars coordinate converter and the MOLA128 DEM
    s = sfRSsim(geom_obj=cc, dem_obj=m, param_obj=pars, n_processes=6
                )  # simulation parameters are contained in the DRSSim class

    # ...or dRSsim:
    # s = dRSsim(geom_obj=cc, dem_obj=m, param_obj=pars, n_processes=6)       # simulation parameters are contained in the DRSSim class

    # EDR PDS
    fn_base = EDR_PDS_INPUT_FILENAME_BASE
    d = EDR_PDS(dataset_name=EDR_PDS_INPUT_DATASET_NAME,
                filename_base=fn_base,
                logger=lg)
    d.load(mode="full")
    d.generate_orbit_data()
    if d.orbit_data is not None:

        # plot the track path on the DEM
        tpod = TrackPlotOnDEM(
            m,
            d.orbit_data["Lat"],
            d.orbit_data["Lon"],
            title="Spacecraft ground track on DEM (full track)")
        tpod.plot()

        # simulate surface clutter radargram
        sim_image, uncert_image, first_return_lats, first_return_lons, ground_distance_min_image, ground_distance_max_image = s.simulate(
            d.orbit_data)

        # save results on disk
        envi.write(EDR_PDS_OUTPUT_SIM_FILENAME_BASE, sim_image)
        envi.write(EDR_PDS_OUTPUT_SIM_FILENAME_BASE + "_uncert", uncert_image)

        # plot the simulated radargram
        # only the top part of the simulation is shown (the top point is calculated dinamically)
        top_point = np.min(
            np.argmin(np.isnan(ground_distance_min_image).astype(int),
                      axis=0)) - 50
        bottom_point = top_point + 1000
        sp = SimulationPlot(
            sim_image,
            top_point=top_point,
            bottom_point=bottom_point,
            title=
            "Radargram simulation with sfRSsim\n(square facets and cos^exp function)"
        )
        sp.plot()

        # plot the track path and the location of the first simulated returns on the DEM
        tfrpod = TrackAndFirstReturnsPlotOnDEM(m, d.orbit_data["Lat"],
                                               d.orbit_data["Lon"],
                                               first_return_lats,
                                               first_return_lons)
        tfrpod.plot()

        # plot the image showing the minimum ground distance from nadir of each simulated range sample
        gdp = GroundDistancePlot(
            ground_distance_min_image / 1000.,
            top_point=top_point,
            bottom_point=bottom_point,
            title=
            "Distance [km] of the closest facet contributing\nto each radargram sample simulation"
        )
        gdp.plot()

        # get the DEM radius profile related to the spacecraft track, to be used later by the focuser
        dem_radius_profile = m.get_dem_radius_from_lat_lon(
            d.orbit_data["Lat"], d.orbit_data["Lon"])

        # free the memory occupied by the DEM (not mandatory, but it may be useful if system RAM is limited)
        del m

        if d.data is not None:
            # create a SOFA instance and focus the input radargram
            f = SOFA(i,
                     cc,
                     dem_radius_profile,
                     d,
                     pars,
                     n_processes=4,
                     debug_mode=True)
            focused_rdr = f.focus()
            if focused_rdr is not None:
                envi.write(
                    EDR_PDS_OUTPUT_FOC_FILENAME_BASE + "_ha-" +
                    str(pars.frame_half_aperture) + "_s-" +
                    str(pars.squint_angle), focused_rdr)

                # plot the focused radargram
                rp = RadargramPlot(focused_rdr,
                                   top_point=top_point,
                                   bottom_point=bottom_point,
                                   title="Radargram")
                rp.plot()