src/PFCoordinateRotation.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 PFCoordinateRotation extends ConfigurableStop{
12 val authorEmail: String = "ygang@cnic.cn"
13 val description: String = "Plane fitting rotation(PF)"
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 u_star: String = _
22 var cov_Uz_Uz :String = _
23 var cov_Uz_Ux :String = _
24 var cov_Uz_Uy :String = _
25 var cov_Uz_co2 :String = _
26 var cov_Uz_h2o :String = _
27 var cov_Uz_Ts :String = _
28 var cov_Ux_Ux :String = _
29 var cov_Ux_Uy :String = _
30 var cov_Ux_co2 :String = _
31 var cov_Ux_h2o :String = _
32 var cov_Ux_Ts :String = _
33 var cov_Uy_Uy :String = _
34 var cov_Uy_co2 :String = _
35 var cov_Uy_h2o :String = _
36 var cov_Uy_Ts :String = _
37 var Ux_Avg :String = _
38 var Uy_Avg :String = _
39 var Uz_Avg :String = _
40
41 override def perform(in: JobInputStream, out: JobOutputStream, pec: JobContext): Unit = {
42 val spark = pec.get[SparkSession]()
43 val originDF = in.read()
44
45 val fluxDataCorrection = new FluxDataCorrectionUtil_2
46 val df = fluxDataCorrection.PFCoordinateRotationUtil(spark,originDF
47 ,Fc
48 ,Le
49 ,Hs
50 ,u_star
51 ,cov_Uz_Uz
52 ,cov_Uz_Ux
53 ,cov_Uz_Uy
54 ,cov_Uz_co2
55 ,cov_Uz_h2o
56 ,cov_Uz_Ts
57 ,cov_Ux_Ux
58 ,cov_Ux_Uy
59 ,cov_Ux_co2
60 ,cov_Ux_h2o
61 ,cov_Ux_Ts
62 ,cov_Uy_Uy
63 ,cov_Uy_co2
64 ,cov_Uy_h2o
65 ,cov_Uy_Ts
66 ,Ux_Avg
67 ,Uy_Avg
68 ,Uz_Avg
69 )
70
71 out.write(df)
72 }
73
74 override def setProperties(map: Map[String, Any]): Unit = {
75 Fc = MapUtil.get(map,"Fc").asInstanceOf[String]
76 Le = MapUtil.get(map,"Le").asInstanceOf[String]
77 Hs = MapUtil.get(map,"Hs").asInstanceOf[String]
78 u_star = MapUtil.get(map,"u_star").asInstanceOf[String]
79 cov_Uz_Uz = MapUtil.get(map,"cov_Uz_Uz").asInstanceOf[String]
80 cov_Uz_Ux = MapUtil.get(map,"cov_Uz_Ux").asInstanceOf[String]
81 cov_Uz_Uy = MapUtil.get(map,"cov_Uz_Uy").asInstanceOf[String]
82 cov_Uz_co2 = MapUtil.get(map,"cov_Uz_co2").asInstanceOf[String]
83 cov_Uz_h2o = MapUtil.get(map,"cov_Uz_h2o").asInstanceOf[String]
84 cov_Uz_Ts = MapUtil.get(map,"cov_Uz_Ts").asInstanceOf[String]
85 cov_Ux_Ux = MapUtil.get(map,"cov_Ux_Ux").asInstanceOf[String]
86 cov_Ux_Uy = MapUtil.get(map,"cov_Ux_Uy").asInstanceOf[String]
87 cov_Ux_co2 = MapUtil.get(map,"cov_Ux_co2").asInstanceOf[String]
88 cov_Ux_h2o = MapUtil.get(map,"cov_Ux_h2o").asInstanceOf[String]
89 cov_Ux_Ts = MapUtil.get(map,"cov_Ux_Ts").asInstanceOf[String]
90 cov_Uy_co2 = MapUtil.get(map,"cov_Uy_co2").asInstanceOf[String]
91 cov_Uy_h2o = MapUtil.get(map,"cov_Uy_h2o").asInstanceOf[String]
92 cov_Uy_Ts = MapUtil.get(map,"cov_Uy_Ts").asInstanceOf[String]
93 cov_Uy_Uy = MapUtil.get(map,"cov_Uy_Uy").asInstanceOf[String]
94 Ux_Avg = MapUtil.get(map,"Ux_Avg").asInstanceOf[String]
95 Uy_Avg = MapUtil.get(map,"Uy_Avg").asInstanceOf[String]
96 Uz_Avg = MapUtil.get(map,"Uz_Avg").asInstanceOf[String]
97 }
98
99 override def getPropertyDescriptor(): List[PropertyDescriptor] = {
100 var descriptor : List[PropertyDescriptor] = List()
101
102 val Fc =new PropertyDescriptor().name("Fc").displayName("Fc").description("CO2通量").defaultValue("Fc").required(true).example("Fc")
103 val Le =new PropertyDescriptor().name("Le").displayName("Le").description("潜热通量").defaultValue("Le").required(true).example("Le")
104 val Hs =new PropertyDescriptor().name("Hs").displayName("Hs").description("显热通量").defaultValue("Hs").required(true).example("Hs")
105 val u_star =new PropertyDescriptor().name("u_star").displayName("u_star").description("摩擦风速").defaultValue("u_star").required(true).example("u_star")
106 val cov_Uz_Uz =new PropertyDescriptor().name("cov_Uz_Uz").displayName("cov_Uz_Uz").description("垂直风速方差").defaultValue("cov_Uz_Uz").required(true).example("cov_Uz_Uz")
107 val cov_Uz_Ux =new PropertyDescriptor().name("cov_Uz_Ux").displayName("cov_Uz_Ux").description("垂直风速与X方向风速协方差").defaultValue("cov_Uz_Ux").required(true).example("cov_Uz_Ux")
108 val cov_Uz_Uy =new PropertyDescriptor().name("cov_Uz_Uy").displayName("cov_Uz_Uy").description("垂直风速与Y方向风速协方差").defaultValue("cov_Uz_Uy").required(true).example("cov_Uz_Uy")
109
110 val cov_Uz_co2 =new PropertyDescriptor().name("cov_Uz_co2").displayName("cov_Uz_co2").description("垂直风速与CO2密度协方差").defaultValue("cov_Uz_co2").required(true).example("cov_Uz_co2")
111 val cov_Uz_h2o =new PropertyDescriptor().name("cov_Uz_h2o").displayName("cov_Uz_h2o").description("垂直风速与H2O密度协方差").defaultValue("cov_Uz_h2o").required(true).example("cov_Uz_h2o")
112 val cov_Uz_Ts =new PropertyDescriptor().name("cov_Uz_Ts").displayName("cov_Uz_Ts").description("垂直风速与温度协方差").defaultValue("cov_Uz_Ts").required(true).example("cov_Uz_Ts")
113 val cov_Ux_Ux =new PropertyDescriptor().name("cov_Ux_Ux").displayName("cov_Ux_Ux").description("X方向风速方差").defaultValue("cov_Ux_Ux").required(true).example("cov_Ux_Ux")
114 val cov_Ux_Uy =new PropertyDescriptor().name("cov_Ux_Uy").displayName("cov_Ux_Uy").description("X与Y方向风速协方差").defaultValue("cov_Ux_Uy").required(true).example("cov_Ux_Uy")
115
116 val cov_Ux_co2 =new PropertyDescriptor().name("cov_Ux_co2").displayName("cov_Ux_co2").description("X方向风速与CO2密度协方差").defaultValue("cov_Ux_co2").required(true).example("cov_Ux_co2")
117 val cov_Ux_h2o =new PropertyDescriptor().name("cov_Ux_h2o").displayName("cov_Ux_h2o").description("X方向风速与H2O密度协方差").defaultValue("cov_Ux_h2o").required(true).example("cov_Ux_h2o")
118 val cov_Ux_Ts =new PropertyDescriptor().name("cov_Ux_Ts").displayName("cov_Ux_Ts").description("X方向风速与温度协方差").defaultValue("cov_Ux_Ts").required(true).example("cov_Ux_Ts")
119 val cov_Uy_co2 =new PropertyDescriptor().name("cov_Uy_co2").displayName("cov_Uy_co2").description("Y方向风速与CO2密度协方差").defaultValue("cov_Uy_co2").required(true).example("cov_Uy_co2")
120 val cov_Uy_h2o =new PropertyDescriptor().name("cov_Uy_h2o").displayName("cov_Uy_h2o").description("Y方向风速与H2O密度协方差").defaultValue("cov_Uy_h2o").required(true).example("cov_Uy_h2o")
121 val cov_Uy_Ts =new PropertyDescriptor().name("cov_Uy_Ts").displayName("cov_Uy_Ts").description("Y方向风速与温度协方差").defaultValue("cov_Uy_Ts").required(true).example("cov_Uy_Ts")
122 val cov_Uy_Uy =new PropertyDescriptor().name("cov_Uy_Uy").displayName("cov_Uy_Uy").description("Y方向风速方差").defaultValue("cov_Uy_Uy").required(true).example("cov_Uy_Uy")
123
124 val Ux_Avg =new PropertyDescriptor().name("Ux_Avg").displayName("Ux_Avg").description("X方向平均风速").defaultValue("Ux_Avg").required(true).example("Ux_Avg")
125 val Uy_Avg =new PropertyDescriptor().name("Uy_Avg").displayName("Uy_Avg").description("Y方向平均风速").defaultValue("Uy_Avg").required(true).example("Uy_Avg")
126 val Uz_Avg =new PropertyDescriptor().name("Uz_Avg").displayName("Uz_Avg").description("Z方向平均风速").defaultValue("Uz_Avg").required(true).example("Uz_Avg")
127
128 descriptor = Fc :: descriptor
129 descriptor = Le :: descriptor
130 descriptor = Hs :: descriptor
131 descriptor = u_star :: descriptor
132
133 descriptor = cov_Uz_Uz :: descriptor
134 descriptor = cov_Uz_Ux :: descriptor
135 descriptor = cov_Uz_Uy :: descriptor
136
137 descriptor = cov_Uz_co2 :: descriptor
138 descriptor = cov_Uz_h2o :: descriptor
139 descriptor = cov_Uz_Ts :: descriptor
140 descriptor = cov_Ux_Ux :: descriptor
141 descriptor = cov_Ux_Uy :: descriptor
142
143 descriptor = cov_Ux_co2 :: descriptor
144 descriptor = cov_Ux_h2o :: descriptor
145 descriptor = cov_Ux_Ts :: descriptor
146
147 descriptor = cov_Uy_co2 :: descriptor
148 descriptor = cov_Uy_h2o :: descriptor
149 descriptor = cov_Uy_Ts :: descriptor
150 descriptor = cov_Uy_Uy :: descriptor
151
152 descriptor = Ux_Avg :: descriptor
153 descriptor = Uy_Avg :: descriptor
154 descriptor = Uz_Avg :: descriptor
155
156 descriptor
157 }
158
159 override def getIcon(): Array[Byte] = {
160 ImageUtil.getImage("png/Flux/flux.png",this.getClass.getName)
161 }
162
163 override def getGroup(): List[String] = {
164 List("Flux_dataCorrection")
165 }
166
167 override def initialize(ctx: ProcessContext): Unit = {
168
169 }
170
171}