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