Source code

Download source archive ↓

upstream/piflow-bundle/src/main/scala/cn/piflow/bundle/flux/dataCorrection/WplCorrection.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
10class WplCorrection extends ConfigurableStop{
11  val authorEmail: String = "ygang@cnic.cn"
12  val description: String = "WPL correction"
13  val inportList: List[String] = List(Port.DefaultPort)
14  val outportList: List[String] = List(Port.DefaultPort)
15
16  var Fc: String = _
17  var Le: String = _
18  var Hs: String = _
19
20  var co2_Avg: String = _
21  var h2o_Avg: String = _
22  var Ts_Avg: String = _
23  var rho_a_Avg: String = _
24
25  override def perform(in: JobInputStream, out: JobOutputStream, pec: JobContext): Unit = {
26    val spark = pec.get[SparkSession]()
27    val originDF = in.read()
28
29    val fluxDataCorrection = new FluxDataCorrectionUtil_2
30    val df = fluxDataCorrection.wplCorrectionUtil(spark,originDF
31      ,Fc
32      ,Le
33      ,Hs
34      ,co2_Avg
35      ,h2o_Avg
36      ,Ts_Avg
37      ,rho_a_Avg
38    )
39
40    out.write(df)
41  }
42
43  override def setProperties(map: Map[String, Any]): Unit = {
44    Fc = MapUtil.get(map,"Fc").asInstanceOf[String]
45    Le = MapUtil.get(map,"Le").asInstanceOf[String]
46    Hs = MapUtil.get(map,"Hs").asInstanceOf[String]
47    co2_Avg = MapUtil.get(map,"co2_Avg").asInstanceOf[String]
48    h2o_Avg = MapUtil.get(map,"h2o_Avg").asInstanceOf[String]
49    Ts_Avg = MapUtil.get(map,"Ts_Avg").asInstanceOf[String]
50    rho_a_Avg = MapUtil.get(map,"rho_a_Avg").asInstanceOf[String]
51
52  }
53
54  override def getPropertyDescriptor(): List[PropertyDescriptor] = {
55    var descriptor : List[PropertyDescriptor] = List()
56
57    val  Fc         =new PropertyDescriptor().name("Fc").displayName("Fc").description("CO2通量").defaultValue("Fc").required(true).example("Fc")
58    val  Le         =new PropertyDescriptor().name("Le").displayName("Le").description("潜热通量").defaultValue("Le").required(true).example("Le")
59    val  Hs         =new PropertyDescriptor().name("Hs").displayName("Hs").description("显热通量").defaultValue("Hs").required(true).example("Hs")
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
76    descriptor
77  }
78
79  override def getIcon(): Array[Byte] = {
80    ImageUtil.getImage("png/Flux/flux.png",this.getClass.getName)
81  }
82
83  override def getGroup(): List[String] = {
84    List("Flux_dataCorrection")
85  }
86
87  override def initialize(ctx: ProcessContext): Unit = {
88
89  }
90
91}