Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marie Latil
Remote Sensing Projects
Commits
35b50137
Commit
35b50137
authored
Apr 29, 2021
by
Marie Latil
Browse files
Update map_seul.py
parent
55d4fbc9
Changes
1
Hide whitespace changes
Inline
Side-by-side
4-pollution/code/map_seul.py
View file @
35b50137
import
numpy
as
np
import
matplotlib.pyplot
as
plt
from
netCDF4
import
Dataset
from
matplotlib.colors
import
LogNorm
import
os
os
.
environ
[
'PROJ_LIB'
]
=
r
'C:\Users\gauth_000\Documents\miniconda3\pkgs\proj4-5.2.0-ha925a31_1\Library\share'
from
mpl_toolkits.basemap
import
Basemap
#Carte à faire
nom_fichier
=
'S5P_OFFL_L2__NO2____100320.nc'
fh
=
Dataset
(
nom_fichier
,
mode
=
'r'
)
long
=
fh
.
groups
[
'PRODUCT'
].
variables
[
'longitude'
][:][
0
,:,:]
lat
=
fh
.
groups
[
'PRODUCT'
].
variables
[
'latitude'
][:][
0
,:,:]
#shape pour faire les for
shape_long
=
fh
.
groups
[
'PRODUCT'
].
variables
[
'longitude'
].
shape
#donnée
no
=
fh
.
groups
[
'PRODUCT'
].
variables
[
'nitrogendioxide_tropospheric_column_precision'
][
0
,:,:]
qa
=
fh
.
groups
[
'PRODUCT'
].
variables
[
'qa_value'
][:][
0
,:,:]
shape
=
fh
.
groups
[
'PRODUCT'
].
variables
[
'nitrogendioxide_tropospheric_column_precision'
].
shape
#nombre de pixel pris en compte (qa valide)
pix
=
np
.
zeros
([
shape
[
1
],
shape
[
2
]])
#on fait la moyenne
for
i
in
range
(
0
,
shape
[
1
]):
#pourcentage pour voir l'avancement
print
(
float
(
i
/
shape
[
1
]))
for
j
in
range
(
0
,
shape
[
2
]):
if
no
[
i
][
j
]
!=
0
:
#pixel nul?
pix
[
i
][
j
]
=
1
m
=
Basemap
(
width
=
1000000
,
height
=
1000000
,
resolution
=
'l'
,
projection
=
'stere'
,
lat_0
=
45.1667
,
lon_0
=
5.717
)
xi
,
yi
=
m
(
long
,
lat
)
# Plot Data
cs
=
m
.
pcolor
(
xi
,
yi
,
np
.
squeeze
(
no
),
vmin
=
1e-5
,
vmax
=
9e-4
,
norm
=
LogNorm
(),
cmap
=
'jet'
)
#add grid
m
.
drawparallels
(
np
.
arange
(
-
80.
,
81.
,
10.
),
labels
=
[
1
,
0
,
0
,
0
],
fontsize
=
5
)
m
.
drawmeridians
(
np
.
arange
(
-
180.
,
181.
,
10.
),
labels
=
[
0
,
0
,
0
,
1
],
fontsize
=
5
)
#Add coastlines, states and country
m
.
drawcoastlines
()
m
.
drawcountries
()
# Add Colorbar
no2_units
=
fh
.
groups
[
'PRODUCT'
].
variables
[
'nitrogendioxide_tropospheric_column_precision'
].
units
cbar
=
m
.
colorbar
(
cs
,
location
=
'bottom'
,
pad
=
"10%"
)
cbar
.
set_label
(
no2_units
)
# Add Title
plt
.
title
(
'NO2 in atmosphere'
)
plt
.
savefig
(
'No1'
,
dpi
=
600
)
plt
.
show
()
import
numpy
as
np
import
matplotlib.pyplot
as
plt
from
netCDF4
import
Dataset
from
matplotlib.colors
import
LogNorm
import
os
os
.
environ
[
'PROJ_LIB'
]
=
r
'C:\Users\gauth_000\Documents\miniconda3\pkgs\proj4-5.2.0-ha925a31_1\Library\share'
from
mpl_toolkits.basemap
import
Basemap
#Carte à faire
nom_fichier
=
'S5P_OFFL_L2__NO2____100320.nc'
fh
=
Dataset
(
nom_fichier
,
mode
=
'r'
)
long
=
fh
.
groups
[
'PRODUCT'
].
variables
[
'longitude'
][:][
0
,:,:]
lat
=
fh
.
groups
[
'PRODUCT'
].
variables
[
'latitude'
][:][
0
,:,:]
#shape pour faire les for
shape_long
=
fh
.
groups
[
'PRODUCT'
].
variables
[
'longitude'
].
shape
#donnée
no
=
fh
.
groups
[
'PRODUCT'
].
variables
[
'nitrogendioxide_tropospheric_column_precision'
][
0
,:,:]
qa
=
fh
.
groups
[
'PRODUCT'
].
variables
[
'qa_value'
][:][
0
,:,:]
shape
=
fh
.
groups
[
'PRODUCT'
].
variables
[
'nitrogendioxide_tropospheric_column_precision'
].
shape
#nombre de pixel pris en compte (qa valide)
pix
=
np
.
zeros
([
shape
[
1
],
shape
[
2
]])
#on fait la moyenne
for
i
in
range
(
0
,
shape
[
1
]):
#pourcentage pour voir l'avancement
print
(
float
(
i
/
shape
[
1
]))
for
j
in
range
(
0
,
shape
[
2
]):
if
no
[
i
][
j
]
!=
0
:
#pixel nul?
pix
[
i
][
j
]
=
1
m
=
Basemap
(
width
=
1000000
,
height
=
1000000
,
resolution
=
'l'
,
projection
=
'stere'
,
lat_0
=
45.1667
,
lon_0
=
5.717
)
xi
,
yi
=
m
(
long
,
lat
)
# Plot Data
cs
=
m
.
pcolor
(
xi
,
yi
,
np
.
squeeze
(
no
),
vmin
=
1e-5
,
vmax
=
9e-4
,
norm
=
LogNorm
(),
cmap
=
'jet'
)
#add grid
m
.
drawparallels
(
np
.
arange
(
-
80.
,
81.
,
10.
),
labels
=
[
1
,
0
,
0
,
0
],
fontsize
=
5
)
m
.
drawmeridians
(
np
.
arange
(
-
180.
,
181.
,
10.
),
labels
=
[
0
,
0
,
0
,
1
],
fontsize
=
5
)
#Add coastlines, states and country
m
.
drawcoastlines
()
m
.
drawcountries
()
# Add Colorbar
no2_units
=
fh
.
groups
[
'PRODUCT'
].
variables
[
'nitrogendioxide_tropospheric_column_precision'
].
units
cbar
=
m
.
colorbar
(
cs
,
location
=
'bottom'
,
pad
=
"10%"
)
cbar
.
set_label
(
no2_units
)
# Add Title
plt
.
title
(
'NO2 in atmosphere'
)
plt
.
savefig
(
'No1'
,
dpi
=
600
)
plt
.
show
()
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment