Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EBVCubeVisualizerPlugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
no67wuwu
EBVCubeVisualizerPlugin
Commits
aba5f2c5
Commit
aba5f2c5
authored
2 years ago
by
Emmanuel Oceguera Conchas
Browse files
Options
Downloads
Patches
Plain Diff
the fuction displayData is working, however there is some issuse
parent
af6e12cc
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
netCDF_visualizer_funtionality.py
+41
-24
41 additions, 24 deletions
netCDF_visualizer_funtionality.py
with
41 additions
and
24 deletions
netCDF_visualizer_funtionality.py
+
41
−
24
View file @
aba5f2c5
...
...
@@ -141,7 +141,7 @@ class maskAndFuntionality (BASE, WIDGET):
else
:
#if the text space is not empty
path
=
self
.
text_set
.
text
()
#we get the path from the text space
ncFile
=
nc
.
Dataset
(
path
,
'
r
'
,
format
=
'
NETCDF4
'
I
ncFile
=
nc
.
Dataset
(
path
,
'
r
'
,
format
=
'
NETCDF4
'
)
ncFileName
=
os
.
path
.
basename
(
path
)
ncFileTitle
=
ncFile
.
title
#convert file name and file title into a QTreeWidgetItem
...
...
@@ -195,21 +195,34 @@ class maskAndFuntionality (BASE, WIDGET):
def
setMapData
(
self
):
"""
This function sets the entities, time, scenarios and metrics in the QComboBox
"""
#we clear the QComboBox
self
.
cbox_entity
.
clear
()
self
.
cbox_time
.
clear
()
self
.
cbox_scenarios
.
clear
()
self
.
cbox_metric
.
clear
()
#we get the path from the text space
path
=
self
.
text_set
.
text
()
ncFile
=
nc
.
Dataset
(
path
,
'
r
'
,
format
=
'
NETCDF4
'
)
metric
s
=
list
(
ncFile
.
groups
.
keys
())
#we get the metrics (name of the groups)
scenario
s
=
list
(
ncFile
.
groups
[
metric
s
[
0
]].
groups
.
keys
())
#we get the scenarios(name of the groups of the groups)
group
s
=
list
(
ncFile
.
groups
.
keys
())
#we get the metrics (name of the groups)
groupsOfGroup
s
=
list
(
ncFile
.
groups
[
group
s
[
0
]].
groups
.
keys
())
#we get the scenarios(name of the groups of the groups)
#set scenario and metric in the QComboBox
#if there ist just group in the file we set it in the cbox_metric and if there is groups of the groups we set the first group in the cbox_scenario
if
len
(
metrics
)
==
1
:
#if there is just one group
self
.
cbox_metric
.
addItems
(
metrics
)
elif
len
(
metrics
)
>
1
:
#if there is more than one group
self
.
cbox_scenarios
.
addItems
(
scenarios
)
self
.
cbox_metric
.
addItems
(
metrics
)
#set scenario and metric in the QComboBox
#if there is just groups we set the groups in the cbox_metric
self
.
cbox_metric
.
addItems
(
groups
)
self
.
cbox_scenarios
.
addItem
(
"
not scenarios
"
)
self
.
cbox_scenarios
.
setEnabled
(
False
)
if
len
(
groupsOfGroups
)
>
0
:
self
.
cbox_scenarios
.
setEnabled
(
True
)
self
.
cbox_scenarios
.
clear
()
self
.
cbox_scenarios
.
addItems
(
groups
)
self
.
cbox_metric
.
clear
()
self
.
cbox_metric
.
addItems
(
groupsOfGroups
)
else
:
pass
#here we are gonna get the entities and the time of the netCDF file and set them into a QComboBox if the top level is clicked
#we get the time of the netCDF file
...
...
@@ -314,25 +327,29 @@ class maskAndFuntionality (BASE, WIDGET):
#entity selected in the QComboBox
entitySelected
=
self
.
cbox_entity
.
currentText
()
entityIndex
=
entityScope
.
index
(
entitySelected
)
#we get the index of the entity selected
#we have to get the scenarios and the metrics from the interface
#if we click on the ebv_cube item in the QTreeWidget we get the name group and the group of the group and turn the row grey
if
self
.
tree_data
.
currentItem
().
text
(
0
)
==
'
ebv_cube
'
:
self
.
tree_data
.
currentItem
().
setBackground
(
0
,
QBrush
(
QColor
(
200
,
200
,
200
)))
#we get the name of the group
groupName
=
self
.
tree_data
.
currentItem
().
parent
().
text
(
0
)
groupOfGroupName
=
self
.
tree_data
.
currentItem
().
parent
().
parent
().
text
(
0
)
#if there not a group of the gorup we create a uri to add the raster layer just with the group name
if
'
groupOfGroupName
'
not
in
locals
():
uri
=
r
'
NETCDF:
"'
+
path
+
'"
:
'
+
groupName
+
'
/ebv_cube
'
else
:
uri
=
r
'
NETCDF:
"'
+
path
+
'"
:
'
+
groupOfGroupName
+
'
/
'
+
groupName
+
'
/ebv_cube
'
#get the scenarios and the metrics from the interface
#scenarios
scenarioSelected
=
self
.
cbox_scenarios
.
currentText
()
scenarioIndex
=
self
.
cbox_scenarios
.
currentIndex
()
#metrics
metricSelected
=
self
.
cbox_metric
.
currentText
()
metricIndex
=
self
.
cbox_metric
.
currentIndex
()
uri
=
r
'
NETCDF:
"'
+
path
+
'"
:
'
+
metricSelected
+
'
/ebv_cube
'
#if there just metrics and no scenarios we have to create a uri with the metric selected in the QComboBox
# if scenarioIndex == 0:
# uri = r'NETCDF:"'+ path + '":' + metricSelected + '/ebv_cube'
# else:
# uri = r'NETCDF:"'+ path + '":'+ scenarioSelected + '/' + metricSelected + '/ebv_cube'
#load the raster layer into the QGIS canvas
rasterLayer
=
QgsRasterLayer
(
uri
,
nameOfRasterLayer
,
"
gdal
"
)
print
(
rasterLayer
,
isValid
())
print
(
rasterLayer
.
isValid
())
#calculate the band number
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment