-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add a file containing functions applying filters depending of each observatory * add new file for distribution * update distribution according to the new filters * install requirements update * install requirements update * force update of fink-filters * update test data according to the new filters * test * save data * restore test data from main * add data for the distribution --------- Co-authored-by: FusRoman <[email protected]>
- Loading branch information
Showing
9 changed files
with
107 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
from pyspark.sql import functions as F | ||
|
||
from fink_utils.broker.distributionUtils import write_to_kafka | ||
from fink_filters.filter_mm_module.filter import ( | ||
f_grb_bronze_events, | ||
f_grb_silver_events, | ||
f_grb_gold_events, | ||
f_gw_bronze_events, | ||
) | ||
|
||
|
||
def apply_filters( | ||
df_stream, | ||
schema, | ||
tinterval, | ||
checkpointpath_grb, | ||
kafka_broker_server, | ||
username, | ||
password, | ||
): | ||
df_grb_bronze = ( | ||
df_stream.withColumn( | ||
"f_bronze", | ||
f_grb_bronze_events( | ||
df_stream["fink_class"], df_stream["observatory"], df_stream["rb"] | ||
), | ||
) | ||
.filter("f_bronze == True") | ||
.drop("f_bronze") | ||
) | ||
|
||
df_grb_silver = ( | ||
df_stream.withColumn( | ||
"f_silver", | ||
f_grb_silver_events( | ||
df_stream["fink_class"], | ||
df_stream["observatory"], | ||
df_stream["rb"], | ||
df_stream["grb_proba"], | ||
), | ||
) | ||
.filter("f_silver == True") | ||
.drop("f_silver") | ||
) | ||
|
||
df_grb_gold = ( | ||
df_stream.withColumn( | ||
"f_gold", | ||
f_grb_gold_events( | ||
df_stream["fink_class"], | ||
df_stream["observatory"], | ||
df_stream["rb"], | ||
df_stream["grb_proba"], | ||
df_stream["rate"], | ||
), | ||
) | ||
.filter("f_gold == True") | ||
.drop("f_gold") | ||
) | ||
|
||
df_gw_bronze = ( | ||
df_stream.withColumn( | ||
"f_bronze", | ||
f_gw_bronze_events( | ||
df_stream["fink_class"], df_stream["observatory"], df_stream["rb"] | ||
), | ||
) | ||
.filter("f_bronze == True") | ||
.drop("f_bronze") | ||
) | ||
|
||
for df_filter, topicname in [ | ||
(df_grb_bronze, "fink_grb_bronze"), | ||
(df_grb_silver, "fink_grb_silver"), | ||
(df_grb_gold, "fink_grb_gold"), | ||
(df_gw_bronze, "fink_gw_bronze"), | ||
]: | ||
checkpointpath_topic = checkpointpath_grb + "/{}_checkpoint".format(topicname) | ||
grb_stream_distribute = write_to_kafka( | ||
df_filter, | ||
F.lit(schema), | ||
kafka_broker_server, | ||
username, | ||
password, | ||
topicname, | ||
checkpointpath_topic, | ||
tinterval, | ||
) | ||
|
||
return grb_stream_distribute |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+16.4 KB
...=2019/month=09/day=03/part-00043-d0a99157-fe17-42a7-a2be-1f56fc5c6571.c000.snappy.parquet
Binary file not shown.
Binary file added
BIN
+16.1 KB
...=2019/month=09/day=03/part-00064-73d02dc2-dbe0-4e73-adc6-a480974420d3.c000.snappy.parquet
Binary file not shown.
Binary file added
BIN
+16.1 KB
...=2019/month=09/day=03/part-00069-60c7f1c4-fdac-4442-9cb1-9834fb0b6c1e.c000.snappy.parquet
Binary file not shown.