Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fireatlas_nrt
Manage
Activity
Members
Labels
Plan
Issues
14
Issue boards
Milestones
Wiki
Code
Merge requests
2
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
gcorradini
fireatlas_nrt
Commits
b6fcd759
Commit
b6fcd759
authored
3 years ago
by
screbec
Browse files
Options
Downloads
Patches
Plain Diff
manage missing NOAA20 data, replace utc day with local day
parent
c2e3bcd4
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
FireIO.py
+32
-26
32 additions, 26 deletions
FireIO.py
with
32 additions
and
26 deletions
FireIO.py
+
32
−
26
View file @
b6fcd759
...
...
@@ -172,6 +172,8 @@ def read_VNP14IMGML(d):
# filter for type and quality (use types 0 (vf) and 3 (offshore))
df
=
df
.
loc
[((
df
[
'
Type
'
]
==
0
)
|
(
df
[
'
Type
'
]
==
3
))
&
((
df
[
'
Confidence
'
]
==
'
nominal
'
)
|
(
df
[
'
Confidence
'
]
==
'
high
'
))]
# add the satellite information
df
=
df
.
assign
(
Sat
=
'
SNPP
'
)
return
df
else
:
return
None
...
...
@@ -215,6 +217,8 @@ def read_VJ114IMGML(yr,mo):
df
[
'
DT
'
],
df
[
'
DS
'
]
=
viirs_pixel_size
(
df
[
'
Sample
'
].
values
)
# filter for confidence
df
=
df
.
loc
[
df
[
'
mask
'
]
>
7
]
# 7:low conf., 8:nominal, 9:high
# add the satellite information
df
=
df
.
assign
(
Sat
=
'
NOAA20
'
)
return
df
else
:
return
None
...
...
@@ -342,32 +346,31 @@ def read_AFPVIIRS(t, sat='SNPP',cols=['Lat','Lon','FRP','Sat','DT','DS','YYYYMMD
else
:
print
(
'
please set SNPP or NOAA20 for sat
'
)
# filter for known spurious pixels
df
=
AFP_spurfilter
(
df
,
t
)
# do regional filtering
df
=
AFP_regfilter
(
df
)
# set ampm
df
=
AFP_setDN
(
df
)
if
df
is
not
None
:
# NOAA data can be empty
# filter for known spurious pixels
df
=
AFP_spurfilter
(
df
,
t
)
# do regional filtering
df
=
AFP_regfilter
(
df
)
# set ampm
df
=
AFP_setDN
(
df
)
# save to temporary file
save_af
(
df
,
d
,
sensor
=
sat
)
# extract active pixels at current time step (day and ampm filter)
df
=
df
.
loc
[(
df
[
'
YYYYMMDD_HHMM
'
].
dt
.
day
==
t
[
2
])]
if
t
[
-
1
]
==
'
pm
'
:
# pm corresponds to daytime (~1.30pm) detections
df
=
df
.
loc
[
df
[
'
DN
'
]
==
'
day
'
]
else
:
df
=
df
.
loc
[
df
[
'
DN
'
]
==
'
night
'
]
# add the satellite information
df
[
'
Sat
'
]
=
sat
# return selected columns; need to change column names first
df_AFP
=
df
[
cols
]
# save to temporary file
save_af
(
df
,
d
,
sensor
=
sat
)
if
df
is
not
None
:
# extract active pixels at current time step (day and ampm filter)
df
=
df
.
loc
[(
df
[
'
date_lst
'
]
==
d
)]
if
t
[
-
1
]
==
'
PM
'
:
# pm corresponds to daytime (~1.30pm) detections
df
=
df
.
loc
[
df
[
'
DN
'
]
==
'
day
'
]
else
:
df
=
df
.
loc
[
df
[
'
DN
'
]
==
'
night
'
]
# return selected columns; need to change column names first
df
=
df
[
cols
]
return
df
_AFP
return
df
def
read_AFP
(
t
,
src
=
'
SNPP
'
):
'''
The wrapper function used to read and extract half-daily active fire
...
...
@@ -393,7 +396,10 @@ def read_AFP(t,src='SNPP'):
if
src
==
'
VIIRS
'
:
import
pandas
as
pd
vlist_SNPP
=
read_AFPVIIRS
(
t
,
sat
=
'
SNPP
'
)
vlist_NOAA20
=
read_AFPVIIRS
(
t
,
sat
=
'
NOAA20
'
)
if
t
[
0
]
>
2017
:
# NOAA data is only availbale form 2018 onwards
vlist_NOAA20
=
read_AFPVIIRS
(
t
,
sat
=
'
NOAA20
'
)
else
:
vlist_NOAA20
=
None
if
vlist_NOAA20
is
None
:
# NOAA20 data is missing for some years and months
vlist
=
vlist_SNPP
else
:
...
...
@@ -877,7 +883,7 @@ def load_id_ted_dict(t):
df
=
pd
.
read_csv
(
fnm
)
# combine the date and time columns to one attribute
df
[
'
ted
'
]
=
df
[
'
ted_year
'
].
astype
(
str
)
+
df
[
'
ted_month
'
].
astype
(
str
).
str
.
zfill
(
2
)
+
df
[
'
ted_day
'
].
astype
(
str
).
str
.
zfill
(
2
)
+
df
[
'
ted_ampm
'
]
df
[
'
ted
'
]
=
df
[
'
ted_year
'
].
astype
(
str
)
+
df
[
'
ted_month
'
].
astype
(
str
).
str
.
zfill
(
2
)
+
df
[
'
ted_day
'
].
astype
(
str
).
str
.
zfill
(
2
)
+
df
[
'
ted_ampm
'
]
# turn back into dictionary
id_ted_dict
=
dict
(
zip
(
df
.
fireid
,
df
.
ted
))
...
...
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