Let's read the RINEX file with Python ①

__RINEX (Receiver Independent Exchange Format) file __ is simply the data received from the satellite by the electronic reference point used in the satellite positioning system. ...maybe By the way, I have almost no knowledge of what kind of information is inside, so I will analyze it appropriately while also practicing the program.

Reference URL -[Positioning Satellite System Wiki](https://ja.wikipedia.org/wiki/%E8%A1%9B%E6%98%9F%E6%B8%AC%E4%BD%8D%E3%82% B7% E3% 82% B9% E3% 83% 86% E3% 83% A0) -What is an electronic reference point (Ministry of Land, Infrastructure, Transport and Tourism)

Configuration environment

First, let's make a GUI (appearance of the tool)

We will use tkinter, which is the standard GUI library that is included from the beginning when Anaconda is installed. Let's code without being too conscious of object orientation!

GUI implementation

analyzer.py


import tkinter as tk
from calendar import isleap
from constant import *  #Own definition module


class Widget:
    """
GUI widget generation class
    """
    def __init__(self):
        self.root = tk.Tk()
        self.root.title('RINEX Analyzer')
        self.root.columnconfigure(0, weight=1)
        self.flame = tk.Frame(self.root)
        self.flame.grid(row=0, column=0)
        [self.flame.columnconfigure(x, weight=1) for x in range(4)]

        #From here onward, the placement of button widgets, etc.
        self.widget_dict = {}
        for cnt,ilist in enumerate(OPTION_LIST):
            tk.Label(self.flame, text=ilist[0].replace("_","\n")).grid(row=0, column=cnt)
            self.widget_dict[ilist[0]] = tk.StringVar()
            if "END" in ilist[0]:
                if not isleap(int(self.widget_dict["YEAR"].get())):
                    self.widget_dict[ilist[0]].set(ilist[1][-2])  #365 if not a leap year
                else:
                    self.widget_dict[ilist[0]].set(ilist[1][-1])  #366 for leap years
            else:
                self.widget_dict[ilist[0]].set(ilist[1][0])
            tk.OptionMenu(self.flame, self.widget_dict[ilist[0]], *ilist[1]).grid(row=1, column=cnt)

        self.widget_dict["GET_RINEX"] = tk.Button(self.flame, text="GET RINEX", bg="SkyBlue")
        self.widget_dict["GET_RINEX"].grid(row=2, column=3, padx=1, pady=1)
        self.widget_dict["GET_RINEX"].config(command=lambda: self.button_event())
        self.widget_dict["TEXT"] = tk.Text(self.flame, width=40, height=10)
        self.widget_dict["TEXT"].grid(row=3, column=0, columnspan=4, padx=5, pady=5)
        self.widget_dict["TEXT"].insert("end", "Message output\n")
        self.widget_dict["CANVAS"] = tk.Canvas(self.flame, width=50, height=50)
        self.widget_dict["CANVAS"].grid(row=4, column=0, columnspan=4)

        self.root.mainloop()

    def button_event(self):
        """
Describe the behavior when the button is pressed
        """
        #Message output to text box
        if int(self.widget_dict["START_DOY"].get()) > int(self.widget_dict["END_DOY"].get()):
            # START_END than DOY_If DOY comes first
            self.widget_dict["TEXT"].insert("end", "START_END than DOY_DOY date comes first\n")
        elif not isleap(int(self.widget_dict["YEAR"].get())):
            #If not a leap year
            if int(self.widget_dict["START_DOY"].get()) == 366 or int(self.widget_dict["END_DOY"].get()) == 366:
                self.widget_dict["TEXT"].insert("end", "{0}There are no 366 days in the year\n".format(self.widget_dict["YEAR"].get()))
            else:
                [self.widget_dict["TEXT"].insert("end", "{0}:{1}\n".format(x, self.widget_dict[x].get())) for x in LABEL_LIST]
        else:
            [self.widget_dict["TEXT"].insert("end", "{0}:{1}\n".format(x, self.widget_dict[x].get())) for x in LABEL_LIST]
        self.widget_dict["TEXT"].see("end")

#Description required when starting a Python file by double-clicking
if __name__ == "__main__":
    try:
        Widget()  #Start interface
        print("\n Normal termination")
    except Exception as _e:
        print(_e, type(_e))
        print("\n Abnormal termination")

Processing leap years was sober and troublesome Or rather, there was a function that could determine if it was a leap year

Own definition module

constant.py


"""Constant definition module"""
YEAR_LIST = ["2018", "2019", "2020", "2021", "2022"]    #Definition for 5 years for the time being
DOY_LIST = [str(x).zfill(3) for x in range(1, 367)]  # Day of year
ERP_LIST = ["0958", "3005", "3007", "3008", "3011",
            "3013","0223", "0224", "0753", "0754", "0755"]  #Station number of electronic reference point...For the time being, let's define the one in Saitama prefecture
LABEL_LIST = ["YEAR", "START_DOY", "END_DOY", "ERP"]
OPTION_LIST = [[LABEL_LIST[cnt], i] for cnt,i in enumerate([YEAR_LIST, DOY_LIST, DOY_LIST, ERP_LIST])]  #Double list

When creating a module that defines constants It seems that there are currently 11 electronic reference points in Saitama Prefecture.

So far, the GUI looks like this

rnx_dler_gui 2020-04-20 224859.png Hmm, tired They ʻOption Menu of tkinter` is called a list box or combo box.

The site I referred to

-[TK Notebook Various Widgets](https://www.nakamuri.info/mw/index.php/%E3%81%84%E3%82%8D%E3%81%84%E3%82%8D% E3% 81% AA% E3% 82% A6% E3% 82% A3% E3% 82% B8% E3% 82% A7% E3% 83% 83% E3% 83% 88) -Create a pull-down menu with DelftStack Tkinter -Ministry of Land, Infrastructure, Transport and Tourism Electronic Reference Point List

last

I have a simple GUI for the time being Next time, I would like to implement around the acquisition of RINEX files. I also felt the ease of use of PyCharm. It's easy to debug, and it feels good to check the syntax and PEP8 conventions without permission.

: arrow_backward: Previous article | [Next article]: arrow_forward:

Recommended Posts

Let's read the RINEX file with Python ①
[Python] Read the csv file and display the figure with matplotlib
Read CSV file with python (Download & parse CSV file)
Check the existence of the file with python
Read the file line by line in Python
Read the file line by line in Python
[Python] Read the specified line in the file
[Automation] Read mail (msg file) with Python
Read a file in Python with a relative path from the program
Read Python csv file
Read table data in PDF file with Python
Convert the character code of the file with Python3
Read line by line from a file with Python
Read the file with python and delete the line breaks [Notes on reading the file]
Python / numpy> Read the data file with the item name line> Use genfromtxt ()
[Implementation example] Read the file line by line with Cython (Python) from the last line
Read csv with python pandas
Template of python script to read the contents of the file
Let's run Excel with Python
I tried to touch the CSV file with Python
Draw netCDF file with python
Read the xml file by referring to the Python tutorial
Read QR code from image file with Python (Mac)
Let's write python with cinema4d.
Read json file with Python, format it, and output json
Call the API with python3.
Let's build git-cat with Python
Download csv file with python
Read json data with python
How to switch the configuration file to be read by Python
Read the GRIB2 file of the Japan Meteorological Agency with pygrib
Let's touch the API of Netatmo Weather Station with Python. #Python #Netatmo
Read the VTK file and display the color map with jupyter.
How to read an Excel file (.xlsx) with Pandas [Python]
I tried to divide the file into folders with Python
Try to decipher the garbled attachment file name with Python
Save the binary file in Python
Implemented file download with Python + Bottle
Let's make a GUI with python.
Follow the file hierarchy with fts
Output to csv file with Python
Get the weather with Python requests
Get the weather with Python requests 2
Create an Excel file with Python3
Let's play with Excel with Python [Beginner]
Hit the Etherpad-lite API with Python
Install the Python plugin with Netbeans 8.0.2
[python] Read information with Redmine API
Have python read the command output
Download the file deployed with appcfg.py
Let's do image scraping with Python
I liked the tweet with python. ..
Extract the targz file using python
Read files in parallel with Python
Master the type with Python [Python 3.9 compatible]
Let's make a graph with python! !!
[Automation with python! ] Part 2: File operation
[Python] Read the Flask source code
Open the file with the default app
Read fbx from python with cinema4d
Let's analyze voice with Python # 1 FFT