Skip to content

Commit

Permalink
Merge pull request #39 from paarnes/dev
Browse files Browse the repository at this point in the history
Update/readme (#38)
  • Loading branch information
paarnes authored Sep 1, 2024
2 parents 88eb687 + 164c5b8 commit ad30791
Show file tree
Hide file tree
Showing 9 changed files with 370 additions and 106 deletions.
10 changes: 5 additions & 5 deletions .devcontainer/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
matplotlib
numpy
pandas
tqdm
zstandard
matplotlib==3.7.5
numpy==1.24.4
pandas==2.0.3
tqdm==4.66.5
zstandard==0.23.0
pytest
332 changes: 270 additions & 62 deletions README.md

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools>=61.0","matplotlib","numpy","pandas","tqdm","zstandard","pytest"]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"


Expand All @@ -9,15 +9,33 @@ version = "1.4.4"
authors = [
{ name="Per Helge Aarnes", email="per.helge.aarnes@gmail.com" },
]
maintainers = [
{ name="Per Helge Aarnes", email="per.helge.aarnes@gmail.com" },
]
description = "A python software that provides comprehensive solutions for GNSS multipath analysis."
readme = "README.md"
readme-content-type = "text/markdown"
requires-python = ">=3.8"
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]

license = { text = "MIT" }
dependencies = [
"matplotlib==3.7.5",
"numpy==1.24.4",
"pandas==2.0.3",
"tqdm==4.66.5",
"zstandard==0.23.0",
"pytest",
]

[project.urls]
"Homepage" = "https://github.com/paarnes/GNSS_Multipath_Analysis_Software"
"Bug Tracker" = "https://github.com/paarnes/GNSS_Multipath_Analysis_Software/issues"
30 changes: 27 additions & 3 deletions src/Examples_on_how_to_run_it.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -39,7 +39,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -189,6 +189,30 @@
"\n",
"navdata = Rinex_v3_Reader().read_rinex_nav(broadcastNav4, data_rate = 120)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from gnssmultipath import GNSS_MultipathAnalysis\n",
"\n",
"outputdir = r\"/workspaces/GNSS_Multipath_Analysis_Software/Output\"\n",
"rinObs = r\"/workspaces/GNSS_Multipath_Analysis_Software/TestData/ObservationFiles/OPEC00NOR_S_20220010000_01D_30S_MO_3.04_croped.rnx\"\n",
"rinNav1 = r\"/workspaces/GNSS_Multipath_Analysis_Software/TestData/NavigationFiles/OPEC00NOR_S_20220010000_01D_CN.rnx\"\n",
"rinNav2 = r\"/workspaces/GNSS_Multipath_Analysis_Software/TestData/NavigationFiles/OPEC00NOR_S_20220010000_01D_EN.rnx\"\n",
"rinNav3 = r\"/workspaces/GNSS_Multipath_Analysis_Software/TestData/NavigationFiles/OPEC00NOR_S_20220010000_01D_GN.rnx\"\n",
"rinNav4 = r\"/workspaces/GNSS_Multipath_Analysis_Software/TestData/NavigationFiles/OPEC00NOR_S_20220010000_01D_RN.rnx\"\n",
"analysisResults = GNSS_MultipathAnalysis(rinObs,\n",
" broadcastNav1=rinNav1,\n",
" broadcastNav2=rinNav2,\n",
" broadcastNav3=rinNav3,\n",
" broadcastNav4=rinNav4,\n",
" plotEstimates=False,\n",
" save_results_as_compressed_pickle=True,\n",
" outputDir=outputdir)"
]
}
],
"metadata": {
Expand All @@ -207,7 +231,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.8"
"version": "3.10.12"
},
"orig_nbformat": 4,
"vscode": {
Expand Down
7 changes: 5 additions & 2 deletions src/gnssmultipath/GNSS_MultipathAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def GNSS_MultipathAnalysis(rinObsFilename: str,
includeObservationOverview: Union[bool, None] = None,
includeLLIOverview: Union[bool, None] = None,
use_LaTex: bool = True
):
) -> dict:

"""
GNSS Multipath Analysis
Expand Down Expand Up @@ -167,6 +167,9 @@ def GNSS_MultipathAnalysis(rinObsFilename: str,
OUTPUTS:
analysisResults: A dictionary that contains alls results of all analysises, for all GNSS systems.
The software is also returning results file. A report provided as a text file, and a CSV file with the estimated values.
--------------------------------------------------------------------------------------------------------------------------
"""
start_time = time.time()
Expand Down Expand Up @@ -780,7 +783,7 @@ def GNSS_MultipathAnalysis(rinObsFilename: str,
pickle_filename = 'analysisResults.pkl'
print(f'\nINFO: The analysis results are being written to the file {pickle_filename}. Please wait..')
results_name = os.path.join(outputDir, pickle_filename)
PickleHandler.write_zstd_pickle(analysisResults, results_name)
PickleHandler.write_pickle(analysisResults, results_name)
print(f'INFO: The analysis results has been written to the file {pickle_filename}.\n')
elif save_results_as_compressed_pickle:
pickle_filename = 'analysisResults.pkl.zst'
Expand Down
11 changes: 5 additions & 6 deletions src/gnssmultipath/make_polarplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import matplotlib.cm as cm
from matplotlib import rc
from matplotlib.ticker import MaxNLocator
from .plotResults import set_linewidt_for_each_object

warnings.filterwarnings("ignore")
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -135,8 +136,8 @@ def make_skyplot(azimut_currentSys, elevation_currentSys, GNSSsystemName,graph_d
# ax.legend(fontsize=14,bbox_to_anchor=(1.40, 0.5),fancybox=True, shadow=True,ncol=2,loc='center right')
legend = ax.legend(fontsize=14,bbox_to_anchor=(1.40, 0.5),fancybox=True, shadow=True,ncol=2,loc='center right')
## Set the linewidth of each legend object (then not dependent of linewith in plot)
for legobj in legend.legendHandles:
legobj.set_linewidth(3.5)
set_linewidt_for_each_object(legend, 3.5)

filename = 'Skyplot_' + GNSSsystemName + '.png'
filename2 = 'Skyplot_' + GNSSsystemName + '.pdf'
# fig.savefig(graph_dir + "/" + filename, dpi=300, orientation='landscape')
Expand Down Expand Up @@ -293,8 +294,7 @@ def plot_SNR_wrt_elev(analysisResults,GNSS_obs, GNSSsystems, obsCodes, graphDir,
ax[0].set_ylabel('[dB-Hz]',fontsize=18,labelpad=10)
ax[0].tick_params(axis='both', labelsize=16)
legend = ax[0].legend(loc='center right',fontsize=12,bbox_to_anchor=(1.25, 0.5), fancybox=True, shadow=True,ncol=2) # frame = legend.get_frame(); frame.set_facecolor((0.89701,0.79902,0.68137)); frame.set_edgecolor('black') #legend
for legobj in legend.legendHandles: # Set the linewidth of each legend object (then not dependent of linewith in plot)
legobj.set_linewidth(1.5)
set_linewidt_for_each_object(legend, 1.5)


## -- Subplot 2
Expand All @@ -313,8 +313,7 @@ def plot_SNR_wrt_elev(analysisResults,GNSS_obs, GNSSsystems, obsCodes, graphDir,
sat_el = sat_elevation[:,PRN]
ax[1].plot(sat_el, SNR_PRN, label='PRN%s' % (PRN),linewidth=0.7)
legend = ax[1].legend(loc='center right',fontsize=12,bbox_to_anchor=(1.25, 0.5), fancybox=True, shadow=True,ncol=2) # frame = legend.get_frame(); frame.set_facecolor((0.89701,0.79902,0.68137)); frame.set_edgecolor('black') #legend
for legobj in legend.legendHandles:
legobj.set_linewidth(1.5)
set_linewidt_for_each_object(legend, 1.5)


filename = 'SNR_' + system + "_" + range1_code + '.pdf'
Expand Down
10 changes: 4 additions & 6 deletions src/gnssmultipath/make_polarplot_dont_use_TEX.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from matplotlib import rc
from matplotlib.ticker import MaxNLocator
from matplotlib.ticker import ScalarFormatter
from .plotResults import set_linewidt_for_each_object

logger = logging.getLogger(__name__)
warnings.filterwarnings("ignore")
Expand Down Expand Up @@ -133,8 +134,7 @@ def make_skyplot_dont_use_TEX(azimut_currentSys, elevation_currentSys, GNSSsyste
# ax.legend(fontsize=14,bbox_to_anchor=(1.40, 0.5),fancybox=True, shadow=True,ncol=2,loc='center right')
legend = ax.legend(fontsize=14,bbox_to_anchor=(1.40, 0.5),fancybox=True, shadow=True,ncol=2,loc='center right')
## Set the linewidth of each legend object (then not dependent of linewith in plot)
for legobj in legend.legendHandles:
legobj.set_linewidth(3.5)
set_linewidt_for_each_object(legend, 3.5)
filename = 'Skyplot_' + GNSSsystemName + '.png'
filename2 = 'Skyplot_' + GNSSsystemName + '.pdf'
# fig.savefig(graph_dir + "/" + filename, dpi=300, orientation='landscape')
Expand Down Expand Up @@ -291,8 +291,7 @@ def plot_SNR_wrt_elev_dont_use_TEX(analysisResults,GNSS_obs, GNSSsystems, obsCod
ax[0].set_ylabel('[dB-Hz]',fontsize=18,labelpad=10)
ax[0].tick_params(axis='both', labelsize=16)
legend = ax[0].legend(loc='center right',fontsize=12,bbox_to_anchor=(1.25, 0.5), fancybox=True, shadow=True,ncol=2) # frame = legend.get_frame(); frame.set_facecolor((0.89701,0.79902,0.68137)); frame.set_edgecolor('black') #legend
for legobj in legend.legendHandles: # Set the linewidth of each legend object (then not dependent of linewith in plot)
legobj.set_linewidth(1.5)
set_linewidt_for_each_object(legend, 1.5)


## -- Subplot 2
Expand All @@ -311,8 +310,7 @@ def plot_SNR_wrt_elev_dont_use_TEX(analysisResults,GNSS_obs, GNSSsystems, obsCod
sat_el = sat_elevation[:,PRN]
ax[1].plot(sat_el, SNR_PRN, label='PRN%s' % (PRN),linewidth=0.7)
legend = ax[1].legend(loc='center right',fontsize=12,bbox_to_anchor=(1.25, 0.5), fancybox=True, shadow=True,ncol=2) # frame = legend.get_frame(); frame.set_facecolor((0.89701,0.79902,0.68137)); frame.set_edgecolor('black') #legend
for legobj in legend.legendHandles:
legobj.set_linewidth(1.5)
set_linewidt_for_each_object(legend, 1.5)


filename = 'SNR_' + system + "_" + range1_code + '.pdf'
Expand Down
46 changes: 30 additions & 16 deletions src/gnssmultipath/plotResults.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@

warnings.filterwarnings("ignore")


def set_linewidt_for_each_object(legend, line_width=1.5):
"""
The function sets the line widt of each object in plot.
Sice matplotlib have changed they name from "legendHandles" to "legend_handles"
a try/except is required.
"""
try:
# Attempt to use the newer attribute name
legend_handles = legend.legend_handles
except AttributeError:
# Fallback to the older attribute name if the newer one doesn't exist
legend_handles = legend.legendHandles

# Now you can safely iterate over legend_handles
for legobj in legend_handles:
legobj.set_linewidth(line_width)


def plotResults(ion_delay_phase1, multipath_range1, sat_elevation_angles,\
tInterval, currentGNSSsystem, range1_Code, range2_Code, phase1_Code, phase2_Code, graphDir):
"""
Expand Down Expand Up @@ -171,8 +191,7 @@ def plotResults(ion_delay_phase1, multipath_range1, sat_elevation_angles,\
# ax3.tick_params(axis='both', labelsize=18)
# legend = ax3.legend(loc='center right',fontsize=14,bbox_to_anchor=(1.28, 0.5), fancybox=True, shadow=True,ncol=2) # frame = legend.get_frame(); frame.set_facecolor((0.89701,0.79902,0.68137)); frame.set_edgecolor('black') #legend
# ## Set the linewidth of each legend object (then not dependent of linewith in plot)
# for legobj in legend.legendHandles:
# legobj.set_linewidth(1.5)
# set_linewidt_for_each_object(legend)

# ax3.grid(color='k', linestyle='-', linewidth=0.1)
# ax3.axhline(y=0.0, color='k', linestyle='-',linewidth=0.4)
Expand Down Expand Up @@ -227,8 +246,7 @@ def plotResults(ion_delay_phase1, multipath_range1, sat_elevation_angles,\
# ax4.tick_params(axis='both', labelsize=18)
# legend = ax4.legend(loc='center right',fontsize=14,bbox_to_anchor=(1.28, 0.5), fancybox=True, shadow=True,ncol=2) # frame = legend.get_frame(); frame.set_facecolor((0.89701,0.79902,0.68137)); frame.set_edgecolor('black') #legend
# ## Set the linewidth of each legend object (then not dependent of linewith in plot)
# for legobj in legend.legendHandles:
# legobj.set_linewidth(1.5)
# set_linewidt_for_each_object(legend)

# ax4.grid(color='k', linestyle='-', linewidth=0.1)
# ax4.axhline(y=0.0, color='k', linestyle='-',linewidth=1)
Expand Down Expand Up @@ -268,9 +286,9 @@ def plotResults(ion_delay_phase1, multipath_range1, sat_elevation_angles,\
ax5[0].set_ylabel('$[m]$',fontsize=20,labelpad=10)
ax5[0].tick_params(axis='both', labelsize=18)
legend = ax5[0].legend(loc='center right',fontsize=12,bbox_to_anchor=(1.25, 0.5), fancybox=True, shadow=True,ncol=2) # frame = legend.get_frame(); frame.set_facecolor((0.89701,0.79902,0.68137)); frame.set_edgecolor('black') #legend

## Set the linewidth of each legend object (then not dependent of linewith in plot)
for legobj in legend.legendHandles:
legobj.set_linewidth(1.5)
set_linewidt_for_each_object(legend)

ax5[0].grid(color='k', linestyle='-', linewidth=0.08)
ax5[0].axhline(y=0.0, color='k', linestyle='-',linewidth=1)
Expand Down Expand Up @@ -309,8 +327,7 @@ def plotResults(ion_delay_phase1, multipath_range1, sat_elevation_angles,\
ax5[1].tick_params(axis='both', labelsize=18)
legend = ax5[1].legend(loc='center right',fontsize=12,bbox_to_anchor=(1.25, 0.5), fancybox=True, shadow=True,ncol=2) # frame = legend.get_frame(); frame.set_facecolor((0.89701,0.79902,0.68137)); frame.set_edgecolor('black') #legend
## Set the linewidth of each legend object (then not dependent of linewith in plot)
for legobj in legend.legendHandles:
legobj.set_linewidth(1.5)
set_linewidt_for_each_object(legend)

ax5[1].grid(color='k', linestyle='-', linewidth=0.08)
ax5[1].axhline(y=0.0, color='k', linestyle='-',linewidth=1)
Expand Down Expand Up @@ -536,8 +553,7 @@ def plotResults_dont_use_TEX(ion_delay_phase1, multipath_range1, sat_elevation_a
# ax3.tick_params(axis='both', labelsize=18)
# legend = ax3.legend(loc='center right',fontsize=14,bbox_to_anchor=(1.28, 0.5), fancybox=True, shadow=True,ncol=2) # frame = legend.get_frame(); frame.set_facecolor((0.89701,0.79902,0.68137)); frame.set_edgecolor('black') #legend
# ## Set the linewidth of each legend object (then not dependent of linewith in plot)
# for legobj in legend.legendHandles:
# legobj.set_linewidth(1.5)
# set_linewidt_for_each_object(legend)

# ax3.grid(color='k', linestyle='-', linewidth=0.1)
# ax3.axhline(y=0.0, color='k', linestyle='-',linewidth=0.4)
Expand Down Expand Up @@ -592,8 +608,7 @@ def plotResults_dont_use_TEX(ion_delay_phase1, multipath_range1, sat_elevation_a
# ax4.tick_params(axis='both', labelsize=18)
# legend = ax4.legend(loc='center right',fontsize=14,bbox_to_anchor=(1.28, 0.5), fancybox=True, shadow=True,ncol=2) # frame = legend.get_frame(); frame.set_facecolor((0.89701,0.79902,0.68137)); frame.set_edgecolor('black') #legend
# ## Set the linewidth of each legend object (then not dependent of linewith in plot)
# for legobj in legend.legendHandles:
# legobj.set_linewidth(1.5)
# set_linewidt_for_each_object(legend)

# ax4.grid(color='k', linestyle='-', linewidth=0.1)
# ax4.axhline(y=0.0, color='k', linestyle='-',linewidth=1)
Expand Down Expand Up @@ -632,9 +647,9 @@ def plotResults_dont_use_TEX(ion_delay_phase1, multipath_range1, sat_elevation_a
ax5[0].set_ylabel('[m]',fontsize=20,labelpad=10)
ax5[0].tick_params(axis='both', labelsize=18)
legend = ax5[0].legend(loc='center right',fontsize=12,bbox_to_anchor=(1.25, 0.5), fancybox=True, shadow=True,ncol=2) # frame = legend.get_frame(); frame.set_facecolor((0.89701,0.79902,0.68137)); frame.set_edgecolor('black') #legend

## Set the linewidth of each legend object (then not dependent of linewith in plot)
for legobj in legend.legendHandles:
legobj.set_linewidth(1.5)
set_linewidt_for_each_object(legend)

ax5[0].grid(color='k', linestyle='-', linewidth=0.08)
ax5[0].axhline(y=0.0, color='k', linestyle='-',linewidth=1)
Expand Down Expand Up @@ -671,8 +686,7 @@ def plotResults_dont_use_TEX(ion_delay_phase1, multipath_range1, sat_elevation_a
ax5[1].tick_params(axis='both', labelsize=18)
legend = ax5[1].legend(loc='center right',fontsize=12,bbox_to_anchor=(1.25, 0.5), fancybox=True, shadow=True,ncol=2) # frame = legend.get_frame(); frame.set_facecolor((0.89701,0.79902,0.68137)); frame.set_edgecolor('black') #legend
## Set the linewidth of each legend object (then not dependent of linewith in plot)
for legobj in legend.legendHandles:
legobj.set_linewidth(1.5)
set_linewidt_for_each_object(legend)

ax5[1].grid(color='k', linestyle='-', linewidth=0.08)
ax5[1].axhline(y=0.0, color='k', linestyle='-',linewidth=1)
Expand Down
10 changes: 5 additions & 5 deletions src/gnssmultipath/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
matplotlib
numpy
pandas
tqdm
zstandard
matplotlib==3.7.5
numpy==1.24.4
pandas==2.0.3
tqdm==4.66.5
zstandard==0.23.0
pytest

0 comments on commit ad30791

Please sign in to comment.