upstream/piflow-bundle/src/main/scala/cn/piflow/bundle/flux/dataCorrection/StorageItemEC.scala
1package cn.piflow.bundle.flux.dataCorrection
2
3import cn.piflow.bundle.flux.util.FluxDataCorrectionUtil_2
4import cn.piflow.conf.bean.PropertyDescriptor
5import cn.piflow.conf.util.{ImageUtil, MapUtil}
6import cn.piflow.conf.{ConfigurableStop, Port}
7import cn.piflow.{JobContext, JobInputStream, JobOutputStream, ProcessContext}
8import org.apache.spark.sql.SparkSession
9
10
11class StorageItemEC extends ConfigurableStop {
12 val authorEmail: String = "ygang@cnic.cn"
13 val description: String = "Fc EC algorithm: Used to estimate variation. Adding to the original value to update the flux"
14 val inportList: List[String] = List(Port.DefaultPort)
15 val outportList: List[String] = List(Port.DefaultPort)
16
17 var Fc : String = _
18// var Le : String = _
19// var Hs : String = _
20 var co2_Avg: String = _
21// var h2o_Avg: String = _
22// var Ts_Avg: String = _
23// var rho_a_Avg: String = _
24
25 var para_H: String = _
26 var flagValue: String = _
27
28
29 override def perform(in: JobInputStream, out: JobOutputStream, pec: JobContext): Unit = {
30 val spark = pec.get[SparkSession]()
31 val flux = new FluxDataCorrectionUtil_2
32 val originDF = in.read()
33
34 val df = flux.FluxEC_new(spark,originDF,Fc,co2_Avg,para_H,flagValue)
35 out.write(df)
36 }
37
38 override def setProperties(map: Map[String, Any]): Unit = {
39 Fc = MapUtil.get(map,"Fc").asInstanceOf[String]
40// Le = MapUtil.get(map,"Le").asInstanceOf[String]
41// Hs = MapUtil.get(map,"Hs").asInstanceOf[String]
42 co2_Avg = MapUtil.get(map,"co2_Avg").asInstanceOf[String]
43// h2o_Avg = MapUtil.get(map,"h2o_Avg").asInstanceOf[String]
44// Ts_Avg = MapUtil.get(map,"Ts_Avg").asInstanceOf[String]
45// rho_a_Avg = MapUtil.get(map,"rho_a_Avg").asInstanceOf[String]
46
47 para_H = MapUtil.get(map, "para_H").asInstanceOf[String]
48 flagValue = MapUtil.get(map, "flagValue").asInstanceOf[String]
49
50 }
51
52 override def getPropertyDescriptor(): List[PropertyDescriptor] = {
53 var descriptor: List[PropertyDescriptor] = List()
54
55 val Fc =new PropertyDescriptor().name("Fc").displayName("Fc").description("CO2通量").defaultValue("Fc").required(true).example("Fc")
56// val Le =new PropertyDescriptor().name("Le").displayName("Le").description("潜热通量").defaultValue("Le").required(true).example("Le")
57// val Hs =new PropertyDescriptor().name("Hs").displayName("Hs").description("显热通量").defaultValue("Hs").required(true).example("Hs")
58
59 val co2_Avg =new PropertyDescriptor().name("co2_Avg").displayName("co2_Avg").description("平均CO2密度").defaultValue("co2_Avg").required(true).example("co2_Avg")
60// val h2o_Avg =new PropertyDescriptor().name("h2o_Avg").displayName("h2o_Avg").description("平均H2O密度").defaultValue("h2o_Avg").required(true).example("h2o_Avg")
61// val Ts_Avg =new PropertyDescriptor().name("Ts_Avg").displayName("Ts_Avg").description("平均超声空气温度").defaultValue("Ts_Avg").required(true).example("Ts_Avg")
62// val rho_a_Avg =new PropertyDescriptor().name("rho_a_Avg").displayName("rho_a_Avg").description("平均空气密度").defaultValue("rho_a_Avg").required(true).example("rho_a_Avg")
63
64
65 descriptor = Fc :: descriptor
66// descriptor = Le :: descriptor
67// descriptor = Hs :: descriptor
68
69 descriptor = co2_Avg :: descriptor
70// descriptor = h2o_Avg :: descriptor
71// descriptor = Ts_Avg :: descriptor
72// descriptor = rho_a_Avg :: descriptor
73
74 val para_Z = new PropertyDescriptor()
75 .name("para_H")
76 .displayName("para_H")
77 .description("The height of flux observation equipment.")
78 .defaultValue("2")
79 .required(true)
80 .example("2")
81 descriptor = para_Z :: descriptor
82
83 val flagValue = new PropertyDescriptor()
84 .name("flagValue")
85 .displayName("flagValue")
86 .description("质量控制标记值:Quality control marker value")
87 .defaultValue("-9999")
88 .required(true)
89 .example("-9999")
90 descriptor = flagValue :: descriptor
91
92 descriptor
93 }
94
95 override def getIcon(): Array[Byte] = {
96 ImageUtil.getImage("png/Flux/flux.png",this.getClass.getName)
97 }
98
99 override def getGroup(): List[String] = {
100 List("Flux_dataCorrection")
101 }
102
103 override def initialize(ctx: ProcessContext): Unit = {
104
105 }
106}