src/WplCorrection.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
11class WplCorrection extends ConfigurableStop{
12 val authorEmail: String = "ygang@cnic.cn"
13 val description: String = "WPL correction"
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
21 var co2_Avg: String = _
22 var h2o_Avg: String = _
23 var Ts_Avg: String = _
24 var rho_a_Avg: String = _
25
26 override def perform(in: JobInputStream, out: JobOutputStream, pec: JobContext): Unit = {
27 val spark = pec.get[SparkSession]()
28 val originDF = in.read()
29
30 val fluxDataCorrection = new FluxDataCorrectionUtil_2
31 val df = fluxDataCorrection.wplCorrectionUtil(spark,originDF
32 ,Fc
33 ,Le
34 ,Hs
35 ,co2_Avg
36 ,h2o_Avg
37 ,Ts_Avg
38 ,rho_a_Avg
39 )
40
41 out.write(df)
42 }
43
44 override def setProperties(map: Map[String, Any]): Unit = {
45 Fc = MapUtil.get(map,"Fc").asInstanceOf[String]
46 Le = MapUtil.get(map,"Le").asInstanceOf[String]
47 Hs = MapUtil.get(map,"Hs").asInstanceOf[String]
48 co2_Avg = MapUtil.get(map,"co2_Avg").asInstanceOf[String]
49 h2o_Avg = MapUtil.get(map,"h2o_Avg").asInstanceOf[String]
50 Ts_Avg = MapUtil.get(map,"Ts_Avg").asInstanceOf[String]
51 rho_a_Avg = MapUtil.get(map,"rho_a_Avg").asInstanceOf[String]
52
53 }
54
55 override def getPropertyDescriptor(): List[PropertyDescriptor] = {
56 var descriptor : List[PropertyDescriptor] = List()
57
58 val Fc =new PropertyDescriptor().name("Fc").displayName("Fc").description("CO2通量").defaultValue("Fc").required(true).example("Fc")
59 val Le =new PropertyDescriptor().name("Le").displayName("Le").description("潜热通量").defaultValue("Le").required(true).example("Le")
60 val Hs =new PropertyDescriptor().name("Hs").displayName("Hs").description("显热通量").defaultValue("Hs").required(true).example("Hs")
61 val co2_Avg =new PropertyDescriptor().name("co2_Avg").displayName("co2_Avg").description("平均CO2密度").defaultValue("co2_Avg").required(true).example("co2_Avg")
62 val h2o_Avg =new PropertyDescriptor().name("h2o_Avg").displayName("h2o_Avg").description("平均H2O密度").defaultValue("h2o_Avg").required(true).example("h2o_Avg")
63 val Ts_Avg =new PropertyDescriptor().name("Ts_Avg").displayName("Ts_Avg").description("平均超声空气温度").defaultValue("Ts_Avg").required(true).example("Ts_Avg")
64 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")
65
66
67 descriptor = Fc :: descriptor
68 descriptor = Le :: descriptor
69 descriptor = Hs :: descriptor
70
71 descriptor = co2_Avg :: descriptor
72 descriptor = h2o_Avg :: descriptor
73 descriptor = Ts_Avg :: descriptor
74 descriptor = rho_a_Avg :: descriptor
75
76
77 descriptor
78 }
79
80 override def getIcon(): Array[Byte] = {
81 ImageUtil.getImage("png/Flux/flux.png",this.getClass.getName)
82 }
83
84 override def getGroup(): List[String] = {
85 List("Flux_dataCorrection")
86 }
87
88 override def initialize(ctx: ProcessContext): Unit = {
89
90 }
91
92}