示例#1
0
    def save(self):
        """Commits the image and annotation to new files.
        
        Saves the image and annotation as png files with an alpha channel for merging
        later. If the image is new, it also adds it to the database.
        """
        # parameters for the PIL annotations done in tandem with the seen tkinter annotations
        self.font = ImageFont.truetype("calibrib.ttf", 20) 
        bounds = self.screenshot_canvas.bbox("text")
        self.draw.text((bounds[0], bounds[1]), fill = 'white', 
                        font = self.font, text = self.text_annotation) 
                        #takes the bottom left coordinate of text and places the text on the pillow drawing
        
        if self.new == True: # if the image is being saved from LilSnippy
            FileManagement(self.folder_path).save_image(self.body_info, self.im, self.annotation)
            from markings import GridMark
            GridMark(self.marker_canvas, self.folder_path, self.body_info)
        else: # if the annotations are being edited from Image Viewer
            self.annotation.save(self.folder_path + self.body_info["annotation_file_name"])
        
        self.destroy()
        
        number = FileManagement(self.folder_path).count_bodies(config.all_bodies, False, False, False, False)
        if number == 300: # opens a popup at 300 biondi bodies done
            done_screen = tk.Toplevel()
            done_screen.grab_set()
            success_label = tk.Label(done_screen, text = "You have finished annotating 300 bodies.")
            success_label.pack(side = 'top')

            close_button = tk.Button(done_screen, text = "OK", command = lambda: done_screen.destroy())
            close_button.pack(side = "bottom")
示例#2
0
    def delete_image(self, body_info):
        """Deletes current image.
        
        Deletes the currently selected image's data from the database and resets the information frame and
        button list to reflect the changes.
        
        Args:
            body_info (tuple): Tuple of the information of the body to be deleted
        """
        name = body_info["body_name"]
        number = body_info["body_number"]
        time = body_info["time"]
        fm = FileManagement(self.folder_path)
        fm.delete_img(name, number)
        # refreshes the button list to reflect the new changes
        self._remake_button_list()
        self.filter()
        self.information_frame.destroy()

        # clear the body canvas
        self.biondi_image_canvas.delete("all")

        # deletes the associated marker on the gridfile
        tag = "m" + str(time)
        self.marker_canvas.delete(tag)
        self.marker_canvas.update()
示例#3
0
def capturarNegro():
    data = request.get_json()
    data['errorBd'] = ""
    data['errorCapturaN'] = ""
    data['espectroNegro'] = ""
    sensorTierraVIS = data["sensorTierraVIS"]
    sensorTierraNIR = data["sensorTierraNIR"]
    nombreMisionCrear = data["nombreMisionCrear"]
    tiempoIntegracion = data["tiempoIntegracion"]
    numeroCapturas = data["numeroCapturas"]
    rel_path = '/tmp/archivoTemporalNegro.txt'
    filePath = FileManagement.to_relative(rel_path)
    negroCapturado = []
    if os.path.exists(filePath):
        os.remove(filePath)
    else:
        print("Can not delete the file as it doesn't exists")
    try:
        negroCapturado = capturarNegroRpi(sensorTierraVIS, sensorTierraNIR,
                                          tiempoIntegracion, numeroCapturas)
        valores_espectros.espectroNegro = getFilesNegro(negroCapturado)
        makeImageD(valores_espectros.espectroNegro)
        rel_path = "/tmp/imagenEspectroD.png"
        filePath = FileManagement.to_relative(rel_path)
        with open(filePath, "rb") as image_file:
            encoded_string = base64.b64encode(image_file.read())
            encoded_string = encoded_string.decode("utf-8")
            # print(encoded_string)
        data['espectroNegro'] = encoded_string
    except Exception as errorCapturaN:
        data['errorCapturaN'] = "T"
        raise errorCapturaN
    return json.dumps(data)
    def update_finished(self, grid_id):
        """Updates the database of a finished grid square.

            Sends the grid square over to the database to be marked as complete and be remembered for future 
            use of the folder

            Args:
                grid_id (str): The grid square letter marked as complete

        """
        fin = self.var_fin.get()
        FileManagement(self.folder_path).finish_grid(grid_id, fin)
        self.final_order = FileManagement(self.folder_path).get_grid()
示例#5
0
    def get_data(self):
        """Retrieves user inputs.
        
        Takes the user inputs from the popup and enters them into a data dictionary.
        This dictionary is later entered into the database.
        """
        time_added = int(time())
        body_file_name = str(self.body_type.get()) + "_" + str(time_added)
        annotation_file_name = body_file_name + "_ANNOTATION"
        fm = FileManagement(self.folder_path)

        data = {
            "time":
            time_added,
            "annotator_name":
            self.annotator.get(),
            "body_name":
            self.body_type.get(),
            "body_number":
            fm.count_bodies([self.body_type.get()], False, False, False, False)
            + 1,
            "x":
            self.canvas_x,
            "y":
            self.canvas_y,
            "grid_id":
            self.grid_id,
            "GR":
            self.var_GR.get(),
            "MAF":
            self.var_MAF.get(),
            "MP":
            self.var_MP.get(),
            "unsure":
            self.var_unsure.get(),
            "notes":
            self.notes.get(),
            "body_file_name":
            body_file_name + ".png",
            "annotation_file_name":
            annotation_file_name + ".png",
            "angle":
            None,
            "log":
            None,
            "dprong1":
            None,
            "lprong2":
            None
        }
        return data
 def update_count(self):
     self.body_count.set(
         FileManagement(self.folder_path).count_bodies(
             config.all_bodies, False, False, False, False))
     self.body_count_label.configure(
         text="{0} Bodies Annotated".format(self.body_count.get()))
     self.master.after(2000, self.update_count)
示例#7
0
def guardarNegro():
    data = request.get_json()
    data['errorBd'] = ""
    relPathSrc = '/tmp/archivoTemporalNegro.txt'
    relPathDes = '/tmp/archivoNegro.txt'
    filePathSrc = FileManagement.to_relative(relPathSrc)
    filePathDes = FileManagement.to_relative(relPathDes)
    try:
        copyfile(filePathSrc, filePathDes)
        SpectreManagement.guardarNegro(valores_espectros.id_espectros, [],
                                       valores_espectros.espectroNegro, [], [],
                                       valores_sensores.idSensorTierraVIS)
    except Exception as errorBd:
        data['errorBd'] = "T"
        raise errorBd
    return json.dumps(data)
示例#8
0
def makeImageC(ejeYMakeImage, j):
    ejeY = ""
    ejeX = ""
    espectrocor = []
    wavecor = []
    # global wavelenghtsLista
    ejeXMakeImage = wavelenghtsLista
    ejeY = np.array(ejeYMakeImage, dtype=np.float32)
    ejeX = np.array(ejeXMakeImage, dtype=np.float32)

    for i in range(230, 890):
        espectrocor.append(ejeY[i])
    for i in range(230, 890):
        wavecor.append(ejeX[i])

    plt.figure(1)
    ax = plt.subplot(111)
    plt.plot(wavecor, espectrocor)#, label='Negro')
    ax.set_ylim(min(espectrocor), max(espectrocor))

    plt.legend()
    rutaImagen= "/tmp/imagenEspectroC%s.png" %(str(datetime.datetime.now())[18:19])
    filePath = FileManagement.to_relative(rutaImagen)
    resultadoMakeImage= plt.savefig(filePath, format="png")
    plt.cla()
    plt.clf()
    plt.close()
    return filePath
示例#9
0
def makeImageG(ejeYMakeImage, rutaImagen, lat, lon, alt):
    # global wavelenghtsLista
    ejeY = ""
    ejeX = ""
    espectrocor = []
    wavecor = []
    
    ejeXMakeImage = wavelenghtsLista
    ejeY = np.array(ejeYMakeImage, dtype=np.float32)
    ejeX = np.array(ejeXMakeImage, dtype=np.float32)

    for i in range(230, 890):
        espectrocor.append(ejeY[i])
    for i in range(230, 890):
        wavecor.append(ejeX[i])

    plt.figure(1)
    ax = plt.subplot(111)
    plt.plot(wavecor, espectrocor)#, label='Negro')
    ax.set_ylim(min(espectrocor), max(espectrocor))

    plt.legend()
    # rutaImagen= "D:/Tesis/Api/Flask/imagenEspectroC%s.png" %(str(j))
    resultadoMakeImage= plt.savefig(rutaImagen, format="jpg")
    plt.cla()
    plt.clf()
    plt.close()
    rel_path = '/testy/base.jpg'
    filePath = FileManagement.to_relative(rel_path)
    piexif.transplant(filePath, rutaImagen)
    set_gps_location(rutaImagen, lat, lon, alt)
    return resultadoMakeImage
示例#10
0
def getFilesNegro(negroCapturado):
    negroCapturadoLista = []
    # Guardar txt de la captura
    rel_path = '/tmp/archivoTemporalNegro.txt'
    filePath = FileManagement.to_relative(rel_path)
    appendFile = open(filePath, 'w')
    for i in range(len(negroCapturado)):
        appendFile.write(str(negroCapturado[i]))
    appendFile.close()
    # abrir txt de la captura y gyardar en []
    rel_path = '/tmp/archivoTemporalNegro.txt'
    filePath = FileManagement.to_relative(rel_path)
    with open(filePath, "r") as negrovis:
        for line in negrovis:
            line = line[0:4]
            negroCapturadoLista.append(line)
    return negroCapturadoLista
示例#11
0
def generalized_main():
    FileManager = FileManagement()
    FileConsider = FileConsiderations()
    ZIPMetrics = GeneralMedianVals()
    DATEMetrics = GeneralMedianVals()

    input_file = sys.argv[1]
    output_path = sys.argv[2]

    report = FileManager.file_input(input_file)
    for line in report:
        FileConsider.set_flags(line)
        if FileConsider.check_flags() == False:
            continue
        elif FileConsider.check_flags() == "consider_for_zip":
            ZIPMetrics.medianvals(line, line[0], line[10][0:5])
            ZIPMetrics.update_median_out(line[0], line[10][0:5])
            continue
        elif FileConsider.check_flags() == "consider_for_date":
            DATEMetrics.medianvals(line, line[0], line[13])
            continue
        elif FileConsider.check_flags() == "consider_for_zipdate":
            ZIPMetrics.medianvals(line, line[0], line[10][0:5])
            ZIPMetrics.update_median_out(line[0], line[10][0:5])
            DATEMetrics.medianvals(line, line[0], line[13])
            continue

    FileManager.file_output(outputpath=output_path,
                            outputname="medianvals_by_zip.txt",
                            data=ZIPMetrics.median_out)

    DATEMetrics.calculate_medianvals()
    FileManager.file_output(outputpath=output_path,
                            outputname="medianvals_by_date.txt",
                            data=DATEMetrics.median_out)
示例#12
0
def main():
    # Get and prepare the input file
    file_manager = FileManagement()
    file = file_manager.input_file_get(assembler_file_path)
    assembler_list = file_manager.file_list_get(file)
    assembler_list = file_manager.remove_whitespaces(assembler_list)
    assembler_list_original = assembler_list.copy()
    #print(*assembler_list, sep = "\n")
    #file_manager.file_print(file)
    file_manager.input_file_close(file)

    #print(assembler_list)
    #input()
    decoder = Decoder()
    output_list, pattern = decoder.sequitur_algorithm(assembler_list)
    #pprint.pprint(output_list)
    #pprint.pprint(pattern)

    # Get the compression rates
    original_size = len(assembler_list_original)
    compressed_size = len(output_list)
    for i in pattern:
        compressed_size += len(pattern[i])

    compression_rate = original_size / compressed_size
    #compression_rate = compressed_size / original_size
    space_saving = (1 - compressed_size / original_size) * 100

    # Print out the results
    print("Original size: ", original_size)
    print("Compressed size: ", compressed_size)
    print("Compression rate ", compression_rate)
    print("Space saving {} %".format(space_saving))
示例#13
0
def capturarBlanco():
    valores_sensores.sumaBlanco = 0
    blancoCapturado = []
    # obtener datos del json
    data = request.get_json()
    data['errorBd'] = ""
    data['errorCapturaB'] = ""
    data['espectroBlanco'] = ""
    sensorTierraVIS = data["sensorTierraVIS"]
    sensorTierraNIR = data["sensorTierraNIR"]
    nombreMisionCrear = data["nombreMisionCrear"]
    tiempoIntegracion = data["tiempoIntegracion"]
    numeroCapturas = data["numeroCapturas"]
    rel_path = '/tmp/archivoTemporalBlanco.txt'
    filePath = FileManagement.to_relative(rel_path)
    if os.path.exists(filePath):
        os.remove(filePath)
    else:
        print("Can not delete the file as it doesn't exists")
    try:
        # Comandar sensores para captura
        blancoCapturado = capturarBlancoRpi(sensorTierraVIS, sensorTierraNIR,
                                            tiempoIntegracion, numeroCapturas)
        # construir imagen
        valores_espectros.espectroBlanco = getFilesBlanco(blancoCapturado)
        for i in range(0, len(valores_espectros.espectroBlanco)):
            valores_sensores.sumaBlanco += float(
                valores_espectros.espectroBlanco[i])
        print("limiteCalibracion = " + str(valores_sensores.sumaBlanco))
        # print(a)
        makeImageW(valores_espectros.espectroBlanco)
        rel_path = "/tmp/imagenEspectroW.png"
        filePath = FileManagement.to_relative(rel_path)
        with open(filePath, "rb") as image_file:
            encoded_string = base64.b64encode(image_file.read())
            encoded_string = encoded_string.decode("utf-8")
            # print(encoded_string)
        data['espectroBlanco'] = encoded_string

    except Exception as errorCapturaB:
        data['errorCapturaB'] = "T"
        raise errorCapturaB
        return json.dumps(data)
    return json.dumps(data)
 def show_ignored(self):
     ignored = FileManagement(self.folder_path).query_all_ignored()
     if self.ignored_var.get() == False:
         for coords in ignored:
             tag = "i{0}{1}".format(coords[0], coords[1])
             self.marker_canvas.delete(tag)
     else:
         for coords in ignored:
             GridIgnored(self.marker_canvas, self.folder_path, coords[0],
                         coords[1])
示例#15
0
def getFilesBlanco(blancoCapturado):
    blancoCapturadoLista=[]
    # guardar txt de la captura
    rel_path = '/tmp/archivoTemporalBlanco.txt'
    filePath = FileManagement.to_relative(rel_path)
    appendFile = open(filePath, 'w')
    for i in range(len(blancoCapturado)):
        appendFile.write(str(blancoCapturado[i]))
    appendFile.close()
    #blanco capturado es un array de strings de tamaño 14336 que al escribirse por
    #líneas en el archivo queda de 1024----14336/14
    # abrir txt capura y guardar en []
    rel_path = '/tmp/archivoTemporalBlanco.txt'
    filePath = FileManagement.to_relative(rel_path)
    with open(filePath, "r") as blancovis:
        for line in blancovis:
            line = line[0:4]
            blancoCapturadoLista.append(line)
    # print(blancoCapturadoLista)
    return blancoCapturadoLista
示例#16
0
def guardarBlanco():
    data = request.get_json()
    data['errorBd'] = ""
    relPathSrc = '/tmp/archivoTemporalBlanco.txt'
    relPathDes = '/tmp/archivoBlanco.txt'
    filePathSrc = FileManagement.to_relative(relPathSrc)
    filePathDes = FileManagement.to_relative(relPathDes)
    try:
        copyfile(filePathSrc, filePathDes)
        print(valores_espectros.espectroBlanco)
        SpectreManagement.guardarBlanco(valores_espectros.id_espectros,
                                        valores_espectros.espectroBlanco, [],
                                        [], [],
                                        valores_sensores.idSensorTierraVIS)
    except Exception as errorBd:
        data['errorBd'] = "T"
        print("Error de DB en guardarBlanco: ", errorBd)
        return json.dumps(data)
        raise errorBd
    return json.dumps(data)
        def confirm():
            """Exports images to folder_path.

            Takes case name and folder path and exports biondi images to the designated folder.
            """
            if self.case_name.get() == "" or self.new_folder_path.get() == "/":
                return
            else:
                FileManagement(self.folder_path).export_case(
                    self.new_folder_path.get(), self.case_name.get())
                export.destroy()
示例#18
0
def guardarTodos():
    data = request.get_json()
    data['errorBd'] = ""
    nombreMisionCrear = data['nombreMisionCrear']
    ruta = str(data['ruta'])
    filePath = FileManagement.to_relative(ruta)
    usuario = str(data['usuario'])
    try:
        if os.path.isdir(filePath):
            data['errorCarpeta'] = ""
            idsWaypoints = []
            idsEspectros = []
            latlonsWaypoints = []
            conn = conexion()
            daoMision = DaoMision(conn)
            mision = daoMision.getMisionNombre(nombreMisionCrear)
            idMision = mision.id
            altura = mision.elevacion
            daoWaypoints = DaoWaypoints(conn)
            waypointsList = daoWaypoints.getAllWaypoints2(idMision)
            print(waypointsList[0].id, waypointsList[1].id)  #272" lista de obj
            for i in range(0, len(waypointsList)):
                idsWaypoints.append(waypointsList[i].id)
                latlonsWaypoints.append(waypointsList[i].latlon)
            print(idsWaypoints)  #
            print("J")
            print(latlonsWaypoints)
            for i in range(0, len(idsWaypoints)):
                daoEspway = DaoEspway(conn)
                espway = daoEspway.getEspwayWaypoint(idsWaypoints[i])
                idEspectro = espway.espectros_id
                idsEspectros.append(idEspectro)

            for i in range(0, len(idsEspectros)):
                latlons = latlonsWaypoints[i].split(",")
                rutaG = filePath
                daoEspectros = DaoEspectros(conn)
                espectro = daoEspectros.getEspectros(idsEspectros[i])
                resultado = espectro.resultado
                rutaG += "/Usuario(" + usuario + ")" + "Mision(" + nombreMisionCrear + ")" + "WaypointNumber(" + str(
                    i) + ")"
                # filePath = FileManagement.to_relative(rutaG)
                generate(resultado, rutaG, float(latlons[0]),
                         float(latlons[1]), altura)
            conn.close()
        else:
            data['errorCarpeta'] = "T"
    except Exception as errorBd:
        data['errorBd'] = "T"
        print("Error en guardarTodos: ", errorBd)
        raise errorBd
    finally:
        return json.dumps(data)
    def initiate_markers(self):
        """Initializes marker info in FileManagment.
    
        Creates a marker for every body on the application's startup. Iterates
        through the bodies in the database to do so. Also creates a marker for
        every ignored marker
        """
        data = FileManagement(self.folder_path).query_images(
            config.all_bodies, False, False, False, False)
        for i in data:
            body_info = {}
            x = 0
            for choice in ("time", "body_name", "body_number", "x", "y"):
                body_info[choice] = i[x]
                x += 1
            GridMark(self.marker_canvas, self.folder_path, body_info)

        # generates ignored markers
        ignored = FileManagement(self.folder_path).query_all_ignored()
        for coord in ignored:
            GridIgnored(self.marker_canvas, self.folder_path, coord[0],
                        coord[1])
示例#20
0
def getFilesVuelo(vueloCapturado):
    vueloCapturadoLista=[]
    # guardar txt de la captura
    rel_path = '/tmp/archivoTemporalVuelo.txt'
    filePath = FileManagement.to_relative(rel_path)
    appendFile = open(filePath, 'w')
    for i in range(len(vueloCapturado)):
        appendFile.write(str(vueloCapturado[i]))
    appendFile.close()
    with open(filePath, "r") as blancovis:
        for line in blancovis:
            line = line[0:4]
            vueloCapturadoLista.append(line)
    return vueloCapturadoLista
示例#21
0
    def create_buttons(self, body_param, GR_param, MAF_param, MP_param,
                       unsure_param):
        """Creates the buttons in the button list.
        
        Create a series of buttons reflecting the filter options which the user can click
        to bring up the relevant information and images for the body selected.
        
        Args:
            body_param (list): A list of all the selected bodies for filtering. Enter self.all_bodies
                for a selection of all the body types.
            GR_param (bool): True if sorting by GR.
            MAF_param (bool): True if sorting by MAF.
            MP_param (bool): True if sorting by MP.
            unsure_param (bool): True if sorting by unsure.
        """
        # queries a list of all the selected bodies
        fm = FileManagement(self.folder_path)
        data = fm.query_images(body_param, GR_param, MAF_param, MP_param,
                               unsure_param)

        # loops through generating bodies
        for i in data:
            time = i[0]
            name = i[1]
            number = i[2]
            body_name = "{} {}".format(name, number)
            # each button takes a different command depending on its selected data
            btn = tk.Button(self.interior,
                            height=1,
                            width=20,
                            relief=tk.FLAT,
                            bg="gray99",
                            fg="purple3",
                            font="Dosis",
                            text=body_name,
                            command=lambda i=time: self.open_file(i))
            btn.pack(padx=10, pady=5, side=tk.TOP)
    def show_select_markers(self):
        """Toggles which markers get shown based on the filter

        Takes seconday_selection and body_selection and shows the markers based on those requirements
        from FileManagement.
        """
        all_data = FileManagement(self.folder_path).query_images(
            config.all_bodies, False, False, False, False)
        for i in all_data:
            self.grid_canvas.delete("m" + str(i[0]))

        bodies = self._get_body_selection()
        secondary_selection = self._get_secondary_selection()

        data = FileManagement(self.folder_path).query_images(
            bodies, secondary_selection[0], secondary_selection[1],
            secondary_selection[2], secondary_selection[3])
        for i in data:
            body_info = {}
            x = 0
            for choice in ("time", "body_name", "body_number", "x", "y"):
                body_info[choice] = i[x]
                x += 1
            GridMark(self.marker_canvas, self.folder_path, body_info)
        def create_ignored_marker(event):
            """Event method that adds an ignored marker.

            x and y are the coords of where the mouse clicked. Then converted to canvas coordinates
            which is used to add a marker.
            """
            x = event.x
            y = event.y
            canvas_x = self.marker_canvas.canvasx(x)
            canvas_y = self.marker_canvas.canvasy(y)
            coords = (canvas_x, canvas_y)

            GridIgnored(self.marker_canvas, self.folder_path, canvas_x,
                        canvas_y)
            FileManagement(self.folder_path).add_ignored(coords)
示例#24
0
 def ok(self):
     if (self.l == []) | (self.d == None):
         return
     
     self.body_info["log"], self.body_info["dprong1"], self.body_info["lprong2"] = self.calc_log()
     if self.new:
         ScreenshotEditor(self.body_info, self.folder_path, self.marker_canvas, self.im, True)
     else:
         info = (self.body_info["body_name"], self.body_info["GR"], 
                 self.body_info["MAF"], self.body_info["MP"], 
                 self.body_info["unsure"], self.body_info["notes"], 
                 self.body_info["angle"], self.body_info["log"], 
                 self.body_info["dprong1"], self.body_info["lprong2"],
                 self.body_info["time"])
         FileManagement(self.folder_path).edit_info(info)
         
     self.destroy()
示例#25
0
def main():
    FileManager = FileManagement()
    FileConsider = FileConsiderations()
    Metrics = MedianVals()

    input_file = sys.argv[1]
    output_path = sys.argv[2]

    #input_file = input_path
    #input_file = input_path + "itcont.txt"

    report = FileManager.file_input(input_file)
    #count = 0
    #loop_time = time.time()
    for line in report:
        #if count % 1000 == 0:
        #    print(str(count)+"th line, time per 1000 lines = ---- %s seconds ----" %(time.time() - loop_time))
        #    loop_time = time.time()
        #count += 1
        FileConsider.set_flags(line)
        if FileConsider.check_flags() == False:
            continue
        elif FileConsider.check_flags() == "consider_for_zip":
            Metrics.medianvals_by_zip(line)
            continue
        elif FileConsider.check_flags() == "consider_for_date":
            Metrics.medianvals_by_date(line)
            continue
        elif FileConsider.check_flags() == "consider_for_zipdate":
            Metrics.medianvals_by_zip(line)
            Metrics.medianvals_by_date(line)
            continue

    #print('writing zips')
    FileManager.file_output(outputpath=output_path,
                            outputname="medianvals_by_zip.txt",
                            data=Metrics.medianzip_out)

    #print('calculating dates')
    #calculate_time = time.time()
    Metrics.calculate_medianvals_by_date()
    #print("time to calculate medianvals_by_date = ----------- %s seconds ------------" % (time.time() - calculate_time))
    #print('writing dates')
    FileManager.file_output(outputpath=output_path,
                            outputname="medianvals_by_date.txt",
                            data=Metrics.mediandate_out)
示例#26
0
    def open_file(self, time):
        """Brings up the relevant file information.
        
        When clicking a button, open_file brings up the annotation and body image
        to show in the biondi_image_canvas as well as shows the information about that
        specific body.
        
        Args:
            Time (int): Time added of selected body in unix time.
        """
        body_info = FileManagement(self.folder_path).get_image_time(time)
        self.clear_information_canvas()
        self.show_information(body_info)
        self.open_annotation_image(body_info)

        self.marker_canvas.itemconfig("m" + str(time), fill="red")
        if self.previous_body_time != 0:
            self.marker_canvas.itemconfig("m" + str(self.previous_body_time),
                                          fill="white")
        self.previous_body_time = time
示例#27
0
def main():
    FileManager = FileManagement()
    FileConsider = FileConsiderations()
    Metrics = MedianVals()

    input_file = sys.argv[1]
    output_path = sys.argv[2]

    #report = FileManager.file_input(input_file)
    report = (line.strip().split("|") for line in open(input_file, 'r'))
    for line in report:
        FileConsider.set_flags(line)
        if FileConsider.check_flags() == False:
            continue
        elif FileConsider.check_flags() == "consider_for_zip":
            Metrics.medianvals_by_zip(line)
            continue
        elif FileConsider.check_flags() == "consider_for_date":
            Metrics.medianvals_by_date(line)
            continue
        elif FileConsider.check_flags() == "consider_for_zipdate":
            Metrics.medianvals_by_zip(line)
            Metrics.medianvals_by_date(line)
            continue

    # for line in report:
    #     FileConsider.set_flags(line)
    #     if FileConsider.check_flags() == False:
    #         continue
    #     elif FileConsider.check_flags() == "consider_for_zip":
    #         Metrics.medianvals_by_zip(line)
    #         continue
    #     elif FileConsider.check_flags() == "consider_for_date":
    #         Metrics.medianvals_by_date(line)
    #         continue
    #     elif FileConsider.check_flags() == "consider_for_zipdate":
    #         Metrics.medianvals_by_zip(line)
    #         Metrics.medianvals_by_date(line)
    #         continue

    FileManager.file_output(outputpath=output_path,
                            outputname="medianvals_by_zip.txt",
                            data=Metrics.medianzip_out)

    Metrics.calculate_medianvals_by_date()
    FileManager.file_output(outputpath=output_path,
                            outputname="medianvals_by_date.txt",
                            data=Metrics.mediandate_out)
示例#28
0
def makeImageW(ejeYMakeImage):
    global wavelenghtsLista
    ejeXMakeImage = wavelenghtsLista
    print(len(ejeXMakeImage))
    print(len(ejeYMakeImage))
    # print(ejeXMakeImage)
    ejeY = np.array(ejeYMakeImage, dtype=np.float32)
    ejeX = np.array(ejeXMakeImage, dtype=np.float32)

    plt.figure(1)
    ax = plt.subplot(111)
    plt.plot(ejeX, ejeY)#, label='Negro')
    ax.set_ylim(min(ejeY), max(ejeY))
    plt.legend()
    rutaImagen= "/tmp/imagenEspectroW.png"
    filePath = FileManagement.to_relative(rutaImagen)
    resultadoMakeImage= plt.savefig(filePath, format="png")
    plt.cla()
    plt.clf()
    plt.close()
    return resultadoMakeImage
示例#29
0
def guardarEspectro():
    data = request.get_json()
    data['errorBd'] = ""
    nombreMisionCrear = data['nombreMisionCrear']
    waypointSeleccionado = data['waypointSeleccionado']
    ruta = str(data['ruta'])
    usuario = str(data['usuario'])
    filePath = FileManagement.to_relative(ruta)
    try:
        if os.path.isdir(filePath):
            conn = conexion()
            daoMision = DaoMision(conn)
            mision = daoMision.getMisionNombre(nombreMisionCrear)
            idMision = mision.id
            altura = mision.elevacion
            daoWaypoints = DaoWaypoints(conn)
            wayp = daoWaypoints.getWaypointByNumber(waypointSeleccionado,
                                                    idMision)
            idWayp = wayp.id
            latlon = wayp.latlon.split(",")

            daoEspway = DaoEspway(conn)
            espway = daoEspway.getEspwayWaypoint(idWayp)
            idEspectro = espway.espectros_id

            daoEspectros = DaoEspectros(conn)
            espectro = daoEspectros.getEspectros(idEspectro)
            resultado = espectro.resultado
            conn.close()
            filePath += "/Usuario(" + usuario + ")" + "Mision(" + nombreMisionCrear + ")" + "Waypoint(" + waypointSeleccionado + ")"
            generate(resultado, filePath, float(latlon[0]), float(latlon[1]),
                     altura)
        else:
            data['errorCarpeta'] = "T"
    except Exception as errorBd:
        data['errorBd'] = "T"
        raise errorBd
    finally:
        return json.dumps(data)
示例#30
0
def sensoresVuelo(sensorVueloVIS, sensorVueloNIR, tiempoIntegracion, numeroCapturas, aux):
    global counter
    try:
        if aux == "C":
            print("capturando Vuelo")
            start_time_A = time.time()
            # x = "D:/subtext/splitTest0/Quieto 1 feb/cult2/2mt0.txt"
            # D:\Tesis\Api\Flask\testy\cult2
            if counter > 6:
                counter = 0
            x = "/testy/cult2/inten%s.txt" %(counter)
            file_path = FileManagement.to_relative(x)
            with open(file_path, 'r') as f:
                intensitiesFlask = f.read()
            # sts.runInParallel(read_VIS(b, c), read_NIR(a, c))                                                             #DOUBLE
            # #sts.runInParallel(read_VIS)  # SINGLE
            # if queueTierra.full():  # If both the NIR and VIS spectra have been acquired successfully
            #     # print(queue.qsize()) # The queue size should be 2
            #     wavelengths_NIR, intensities_NIR, wavelengths_VIS, intensities_VIS = sts.assign_spectra(queue, init_wl_NIR, init_wl_VIS)  # SINGLE
            # else:
            #     print("Queue not full")
            end_time_A = time.time()
            duration = end_time_A - start_time_A
            print("Acquisition for {} seconds".format(duration))
            duration = str(duration)
            success = "Success"
            counter += 1
            pass
        else:
            intensitiesFlask = ""
            counter = 0
            # a, b, c = calibrarSensores(sensorVueloVIS, sensorVueloNIR, tiempoIntegracion, numeroCapturas)
            pass
        pass
    except Exception as errorCalibrarSensoresTierra:
        print("error captura/calibracion")
        raise errorCalibrarSensoresTierra
    return intensitiesFlask