-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add setter to fireID property in FireObj.Fire #169
base: conus-dps
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,7 +60,8 @@ def __init__(self, t): | |
self.init_gdf() | ||
|
||
# cumulative recordings | ||
self.heritages = [] # a list of fire heritage relationships (source, target) | ||
# a list of fire heritage relationships (source, target) | ||
self.heritages = [] | ||
self.id_dict = ( | ||
[] | ||
) # this list relates the list position of the fire in the allfires object to the fire id | ||
|
@@ -85,9 +86,11 @@ def init_gdf(self): | |
@classmethod | ||
@timed | ||
def rehydrate(cls, tst, ted, region, allpixels=None, include_dead=False, read_location=None): | ||
allfires_gdf = read_allfires_gdf(tst, ted, region, location=read_location) | ||
allfires_gdf = read_allfires_gdf( | ||
tst, ted, region, location=read_location) | ||
if allpixels is None: | ||
allpixels = read_allpixels(tst, ted, region, location=read_location) | ||
allpixels = read_allpixels( | ||
tst, ted, region, location=read_location) | ||
|
||
dt = t2dt(ted) | ||
|
||
|
@@ -113,13 +116,13 @@ def rehydrate(cls, tst, ted, region, allpixels=None, include_dead=False, read_lo | |
for k, v in gdf_fid_t.items(): | ||
if not isinstance(getattr(Fire, k, None), property): | ||
setattr(f, k, v) | ||
|
||
f.t_st = dt2t(dt_st) | ||
f.t_ed = dt2t(dt_ed) | ||
|
||
if f.mergeid != fid: | ||
allfires.heritages.append((fid, f.mergeid)) | ||
|
||
if f.t_ed == ted: | ||
if f.isignition: | ||
allfires.fids_new.append(fid) | ||
|
@@ -139,7 +142,8 @@ def update_gdf(self): | |
|
||
for fid, f in self.burningfires.items(): | ||
if (fid, dt) in self.gdf.index: | ||
raise ValueError(f"Error writing gdf: {fid} already at {self.t}") | ||
raise ValueError( | ||
f"Error writing gdf: {fid} already at {self.t}") | ||
|
||
for k, tp in dd.items(): | ||
if tp == "datetime64[ns]": | ||
|
@@ -319,7 +323,8 @@ def newyear_reset(self, regnm): | |
fids_keep = self.fids_active + self.fids_sleeper | ||
for i, fid in enumerate(fids_keep): | ||
newfires[i] = self.fires[fid] # record new fireID and fire object | ||
newfires[i].fireID = i # also update fireID attribute of fire object | ||
# also update fireID attribute of fire object | ||
newfires[i].fireID = i | ||
fidmapping.append((fid, i)) | ||
self.fires = newfires | ||
|
||
|
@@ -494,6 +499,10 @@ def isignition(self): | |
def fireID(self): | ||
return self._fid | ||
|
||
@fireID.setter | ||
def fireID(self, newid): | ||
self._fid = newid | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this really enough? Don't we need to explicitly update the backing objects to change the fid from the old one to the new one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh possibly... I can dig into this more. Are there other good fires to look at that go from Dec to Jan? Out of the last 10 years, I've only had one active fire in CA (Thomas 2017) that did that and it was barely active. Possibly some in the southern hemisphere? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am certainly not the person to ask :) maybe ask around on slack or tag people here to pull them into the conversation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey Lisa! Thanks for digging into this. I suspect we can help you find more examples of cross year fires, and actually have put this on the roadmap of things we need to deal with as we scale to global runs. Just so you know, the GSFC team is at AGU this week, so you probably won’t hear much from us in the next few days. However, we do have some southern hemisphere results and I’d be happy to generate more after the conference with an eye towards that Dec 31/Jan 1 crossover. Let’s touch base next week if needed. |
||
|
||
@property | ||
def pixels(self): | ||
return self.allpixels[ | ||
|
@@ -716,16 +725,19 @@ def updatefline(self): | |
|
||
# calculate the fire line | ||
if fhull is None: # if no hull, return None | ||
raise ValueError(f"hull is not set on this fire {self.fireID} at {self.t}") | ||
raise ValueError( | ||
f"hull is not set on this fire {self.fireID} at {self.t}") | ||
if fhull.geom_type == "MultiPolygon": | ||
# extract exterior of fire perimeter | ||
mls = MultiLineString([plg.exterior for plg in fhull.geoms]) | ||
# set fline to the part which intersects with bufferred flinelocsMP | ||
self.fline = mls.intersection(flinelocsMP.buffer(settings.flbuffer)) | ||
self.fline = mls.intersection( | ||
flinelocsMP.buffer(settings.flbuffer)) | ||
|
||
elif fhull.geom_type == "Polygon": | ||
mls = fhull.exterior | ||
self.fline = mls.intersection(flinelocsMP.buffer(settings.flbuffer)) | ||
self.fline = mls.intersection( | ||
flinelocsMP.buffer(settings.flbuffer)) | ||
else: # if fhull type is not 'MultiPolygon' or 'Polygon', return flinelocsMP | ||
self.fline = flinelocsMP | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw this is the only actual change. All the other stuff was style syntax my IDE made. sorry!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah that's fine - comes from a lot of this being written in jupyterhub without linting enabled.