Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

joinTable.R 1.8 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
  1. library(dplyr)
  2. setwd('~/docs/znbt/photovoltaics/HuBeiShaYang/fullTable/')
  3. extract.station.id <- function(raw.info) {
  4. unlist(strsplit(raw.info, '-'))[2]
  5. }
  6. extract.dev.id <- function(raw.info) {
  7. t1 <- unlist(strsplit(raw.info, '-'))
  8. paste(t1[3], '00', t1[4], t1[5], sep = '')
  9. }
  10. probes <- 'probes.csv' %>%
  11. read.table(header = FALSE, sep = ',',
  12. col.names = c('pointID', 'fullDesc', 'remark'),
  13. colClasses = c('integer', 'character', 'integer')) %>%
  14. filter(remark==0) # 只取平单轴测点
  15. probes['STATION_ID'] <- sapply(probes$fullDesc, extract.station.id)
  16. probes['DEVICE_ID'] <- sapply(probes$fullDesc, extract.dev.id)
  17. probe.data <- 'final.csv' %>%
  18. read.table(header = FALSE, sep = ',',
  19. col.names = c('PROBEID', 'MONITOR_TIME', 'CURRENT_VALUE', 'VOLTAGE_VALUE',
  20. 'POWER_VALUE', 'IRRADIANCE', 'TEMPERATURE'),
  21. colClasses = c("integer", "POSIXct", rep("numeric", 5))) # %>%
  22. # filter(CURRENT_VALUE >= 0 & CURRENT_VALUE <=10)
  23. # 去掉无效电流值,这一步在算法中实现,不在此处(数据生成)实现
  24. probe.data %>%
  25. inner_join(probes, by = c('PROBEID' = 'pointID')) %>%
  26. select('STATION_ID', 'DEVICE_ID', 'MONITOR_TIME', 'VOLTAGE_VALUE', 'CURRENT_VALUE',
  27. 'POWER_VALUE', 'TEMPERATURE', 'IRRADIANCE') %>%
  28. arrange(DEVICE_ID, MONITOR_TIME) %>%
  29. write.csv(file = "resR.csv", quote = FALSE, row.names = FALSE)
  30. probe.data %>%
  31. inner_join(probes, by = c('PROBEID' = 'pointID')) %>%
  32. select('DEVICE_ID') %>%
  33. arrange(DEVICE_ID) %>%
  34. unique %>%
  35. write.csv(file = "devR.csv", quote = FALSE, row.names = FALSE)
  36. probe.data %>%
  37. inner_join(probes, by = c('PROBEID' = 'pointID')) %>%
  38. select('DEVICE_ID', 'MONITOR_TIME') %>%
  39. arrange(DEVICE_ID, MONITOR_TIME) %>%
  40. unique %>%
  41. write.csv(file = "devtimeR.csv", quote = FALSE, row.names = FALSE)
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...