Skip to content
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

Cluster of lightning isn't large enough #1

Closed
zxdawn opened this issue Dec 25, 2021 · 2 comments
Closed

Cluster of lightning isn't large enough #1

zxdawn opened this issue Dec 25, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@zxdawn
Copy link
Owner

zxdawn commented Dec 25, 2021

Problem

The observed lightning flashes are clustered first and then classified into clean and polluted clusters.

# cluster lightning data
df_cluster, cluster_labels, hulls = get_cluster(df_lightning)
if df_cluster.empty:
save_data(scn, vnames, cfg, output_file, mask)
logging.info(' '*4+f'No lightning clusters are found for {os.path.basename(filename)}')
return
else:
# classify lightning clusters into clean and polluted (fire) categories
clean_cluster, polluted_cluster = classify_lightning(df_cluster, df_viirs, cluster_labels, hulls)
if not clean_cluster.empty:
logging.info(' '*4+'Calculate the transported clean lighting cluster ...')
clean_cluster = pred_cluster(clean_cluster, t_overpass, ds_era5, wind_levels, cfg)

However, that would split storms using the default 40 km

# search for 40km around each lightning dots
epsilon = 40/kms_per_radian
logging.info(' '*4 + f'Cluster lightning by DBSCAN ...')
db = DBSCAN(eps=epsilon, min_samples=2, algorithm='ball_tree', metric='haversine').fit(np.radians(coords))
cluster_labels = db.labels_

This method works well for isolated storms like this:
The LNO2 were produced and transported with wind:
S5P_PAL__L2__NO2____20190810T212136_20190810T230306_09456_01_020301_1
S5P_PAL__L2__NO2____20190811T004435_20190811T022605_09458_01_020301_1

However, there're some storms that occurred closely but were still far from 40 km. The LNO2 produced by them could mix together:
S5P_PAL__L2__NO2____20190610T051322_20190610T065452_08581_01_020301_1
S5P_PAL__L2__NO2____20190610T170352_20190610T184522_08588_01_020301_1

Solution

It's better to calculated the transported air containing LNO2 first, and then cluster and classify it.

@zxdawn zxdawn added the bug Something isn't working label Dec 25, 2021
@zxdawn zxdawn self-assigned this Dec 25, 2021
@zxdawn
Copy link
Owner Author

zxdawn commented Dec 26, 2021

OK. I come up with this easier idea:

We can set the mask to the minimum value (>0) of previous masks

for index, label in enumerate(labels):
# iterate each label and update the mask
dfq = ds.sel(lightning_label=label)
lon_lat = dfq[['longitude_pred', 'latitude_pred']].stack(all=("level", "lightning_label"))
lightning_points = lon_lat.to_array().transpose('all', ...)
mask = in_hull(pixel_points, lightning_points).reshape(scn['nitrogendioxide_tropospheric_column'].shape, order='F')
if kind == 'clean':
# clean lightning 1abel: 1, 2, ....
lightning_mask = xr.where(mask, index+1, lightning_mask)
elif kind == 'polluted':
# polluted lightning 1abel: -1, -2, ....
lightning_mask = xr.where(mask, -index-1, lightning_mask)

image

@zxdawn zxdawn closed this as completed in 2e1536f Dec 26, 2021
@zxdawn
Copy link
Owner Author

zxdawn commented Dec 26, 2021

The updated image is shown in #2 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant