def _plot_number_of_satellites(dset: "Dataset", figure_dir: "pathlib.PosixPath") -> None: """Plot number of satellites Args: dset: A dataset containing the data. figure_dir: Figure directory """ if "num_satellite_used" not in dset.fields: dset.add_float( "num_satellite_used", val=gnss.get_number_of_satellites(dset.system, dset.satellite, dset.time.gps.datetime), write_level="detail", ) plot( x_arrays=[dset.time.gps.datetime, dset.time.gps.datetime], y_arrays=[dset.num_satellite_available, dset.num_satellite_used], xlabel="Time [GPS]", ylabel="Number of satellites", y_unit="", labels=["Available", "Used"], figure_path=figure_dir / f"plot_number_of_satellites.{FIGURE_FORMAT}", opt_args={"figsize": (7, 4), "legend": True, "marker": ",", "plot_to": "file", "plot_type": "plot"}, )
def gnss_position(dset: "Dataset") -> None: """Write GNSS position results Args: dset: A dataset containing the data. """ file_path = config.files.path("output_dilution_of_precision", file_vars=dset.vars) # Add date and DOPs fields to dataset if "date" not in dset.fields: dset.add_text( "date", val=[d.strftime("%Y/%m/%d %H:%M:%S") for d in dset.time.datetime], unit="YYYY/MM/DD hh:mm:ss") if "pdop" not in dset.fields: gnss_dop(dset) if "num_satellite_used" not in dset.fields: dset.add_float( "num_satellite_used", val=gnss.get_number_of_satellites(dset.system, dset.satellite, dset.time), ) # Put together fields in an array as specified by the 'dtype' tuple list output_list = list() for epoch in dset.unique("time"): idx = dset.filter(time=epoch) # Append current epoch position solution to final output solution output_list.append( tuple([ get_field(dset, f.field, f.attrs, f.unit)[idx][0] for f in FIELDS ])) output_array = np.array(output_list, dtype=[(f.name, f.dtype) for f in FIELDS]) # Write to disk header = get_header( FIELDS, pgm_version=f"where {where.__version__}", run_by=util.get_user_info()["inst_abbreviation"] if "inst_abbreviation" in util.get_user_info() else "", summary="GNSS dilution of precision results", ) np.savetxt( file_path, output_array, fmt=tuple(f.format for f in FIELDS), header="\n".join(header), delimiter="", encoding="utf8", )
def plot_number_of_satellites( self, figure_name: str="plot_gnss_number_of_satellites_epoch.{FIGURE_FORMAT}", ) -> pathlib.PosixPath: """Plot number of satellites based for each GNSS Args: figure_name: File name of figure. Returns: Figure path. """ # Generate x- and y-axis data per system x_arrays = [] y_arrays = [] labels = [] figure_path = self.figure_dir / figure_name.replace("{FIGURE_FORMAT}", self.figure_format) log.debug(f"Plot {figure_path}.") for sys in sorted(self.dset.unique("system")): idx = self.dset.filter(system=sys) x_arrays.append(self.dset.time.gps.datetime[idx]) y_arrays.append(gnss.get_number_of_satellites( self.dset.system[idx], self.dset.satellite[idx], self.dset.time.gps.datetime[idx]) ) labels.append(enums.gnss_id_to_name[sys].value) # Plot scatter plot plot( x_arrays=x_arrays, y_arrays=y_arrays, xlabel="Time [GPS]", ylabel="# satellites", y_unit="", labels=labels, figure_path=figure_path, opt_args={ "figsize": (7, 4), "marker": ",", "legend": True, "legend_location": "bottom", "legend_ncol": len(self.dset.unique("system")), "plot_to": "file", "plot_type": "plot" }, ) return figure_path
def plot_number_of_satellites_used( self, figure_name: str="plot_number_of_satellites_used.{FIGURE_FORMAT}", ) -> pathlib.PosixPath: """Plot available number of satellites against used number Args: figure_name: File name of figure. Returns: Figure path. """ figure_path = self.figure_dir / figure_name.replace("{FIGURE_FORMAT}", self.figure_format) log.debug(f"Plot {figure_path}.") if "num_satellite_used" not in self.dset.fields: self.dset.add_float( "num_satellite_used", val=gnss.get_number_of_satellites( self.dset.system, self.dset.satellite, self.dset.time.gps.datetime), ) plot( x_arrays=[self.dset.time.gps.datetime, self.dset.time.gps.datetime], y_arrays=[self.dset.num_satellite_available, self.dset.num_satellite_used], xlabel="Time [GPS]", ylabel="Number of satellites", y_unit="", labels=["Available", "Used"], figure_path=figure_path, opt_args={ "figsize": (7, 4), "legend": True, "marker": ",", "plot_to": "file", "plot_type": "plot" }, ) return figure_path