first commit
This commit is contained in:
242
HD_filter_ns41.R
Normal file
242
HD_filter_ns41.R
Normal file
@@ -0,0 +1,242 @@
|
||||
## Filter NS41 Data
|
||||
## Michael D. Cayton
|
||||
## March 6th, 2020
|
||||
|
||||
|
||||
# Libraries
|
||||
|
||||
library(tidyverse)
|
||||
library(lubridate)
|
||||
|
||||
# Create Function to calculate decimal day with year to six signigicant digits.
|
||||
|
||||
decimal_day <- function(year, day){
|
||||
if_else (leap_year(year), n<-366, n<-365)
|
||||
decmial_day <- format(year + ((day-1)/n), nsmall=6)
|
||||
print(decmial_day)
|
||||
}
|
||||
|
||||
# Import NS41 file data
|
||||
|
||||
ns41 <- read_csv(file="/Users/mdcay/Documents/Happy Dad/ns41.csv")
|
||||
|
||||
# Put into tibble
|
||||
ns41 <- tbl_df(ns41)
|
||||
|
||||
# Select rows that are needed to filter
|
||||
data <- ns41 %>% select(V1,V5:V20, V22, V23, V25, V29)
|
||||
|
||||
# Filter based on parameters.
|
||||
data <- data %>% filter(V5 > 0.33,
|
||||
V6 > 0.33,
|
||||
V7 > 0.33,
|
||||
V8 > 0.33,
|
||||
V9 > 0.33,
|
||||
V10 > 0.33,
|
||||
V11 > 0.33,
|
||||
V12 > 0.33,
|
||||
V13 > 0.033,
|
||||
V14 > 0.033,
|
||||
V15 > 0.033,
|
||||
V16 > 0.033,
|
||||
V17 > 0.033,
|
||||
V18 > 0.033,
|
||||
V19 > 0.033,
|
||||
V20 > 0.033,
|
||||
V25 == 0,
|
||||
V29 > 20,
|
||||
V29 < 25.2)
|
||||
|
||||
|
||||
# Format data into proper form for Fortran and select only the needed rows.
|
||||
|
||||
data <- data %>% mutate(decimal_date=decimal_day(V22, V1))
|
||||
|
||||
x <- data %>% select(V5:V20) %>% format.data.frame(digits=4, nsmall=3, width=10)
|
||||
|
||||
d <- data %>% transmute(decimal_date = data$decimal_date) %>% format.data.frame(digits=11, nsmall=6, width=11)
|
||||
|
||||
x <- cbind(x,d)
|
||||
|
||||
|
||||
|
||||
|
||||
# Write file to CSV file.
|
||||
write_csv(x, path='C:/Users/mdcay/Documents/Happy Dad/ns41_filter.csv')
|
||||
|
||||
|
||||
###########################################################################
|
||||
|
||||
### Information about the data file ###
|
||||
|
||||
### sum of col V81 through 99
|
||||
### 21 not 240 remove
|
||||
# number of rows, sum
|
||||
# midified Bessal function of the second kind. ### sum of col V81 through 99
|
||||
### 21 not 240 remove
|
||||
# number of rows, sum
|
||||
|
||||
### JSON with table info ###
|
||||
# test <- fromJSON('{
|
||||
# "decimal_day": { "DESCRIPTION":"Decimal Day of year",
|
||||
# "DIMENSION": [1],
|
||||
# "UNITS": "days",
|
||||
# "START_COLUMN": 0
|
||||
# },
|
||||
#
|
||||
# "Geographic_Latitude": { "DESCRIPTION":"Geographic_Latitude",
|
||||
# "DIMENSION": [1],
|
||||
# "UNITS": "degrees",
|
||||
# "START_COLUMN": 1
|
||||
# },
|
||||
# "Geographic_Longitude": { "DESCRIPTION":"Geographic_Longitude",
|
||||
# "DIMENSION": [1],
|
||||
# "UNITS": "degrees",
|
||||
# "START_COLUMN": 2
|
||||
# },
|
||||
# "Rad_Re": { "DESCRIPTION":"Radius (earth radii)",
|
||||
# "DIMENSION": [1],
|
||||
# "UNITS": "R_E",
|
||||
# "START_COLUMN": 3
|
||||
# },
|
||||
# "rate_electron_measured": { "DESCRIPTION":"rate_electron_measured",
|
||||
# "DIMENSION": [8],
|
||||
# "UNITS": "hertz",
|
||||
# "START_COLUMN": 4
|
||||
# },
|
||||
# "rate_proton_measured": { "DESCRIPTION":"rate_proton_measured",
|
||||
# "DIMENSION": [8],
|
||||
# "UNITS": "hertz",
|
||||
# "START_COLUMN": 12
|
||||
# },
|
||||
# "collection_interval": { "DESCRIPTION":"collection_interval",
|
||||
# "DIMENSION": [1],
|
||||
# "UNITS": "seconds",
|
||||
# "START_COLUMN": 20
|
||||
# },
|
||||
# "year": { "DESCRIPTION":"year eg 2015",
|
||||
# "DIMENSION": [1],
|
||||
# "UNITS": "years",
|
||||
# "START_COLUMN": 21
|
||||
# },
|
||||
# "decimal_year": { "DESCRIPTION":"decimal_year contains fractional part of year",
|
||||
# "DIMENSION": [1],
|
||||
# "UNITS": "years",
|
||||
# "START_COLUMN": 22
|
||||
# },
|
||||
# "svn_number": { "DESCRIPTION":"SVN number",
|
||||
# "DIMENSION": [1],
|
||||
# "UNITS": "none",
|
||||
# "START_COLUMN": 23
|
||||
# },
|
||||
# "dropped_data": { "DESCRIPTION":"dropped_data=1 means ignore data",
|
||||
# "DIMENSION": [1],
|
||||
# "UNITS": "none",
|
||||
# "START_COLUMN": 24
|
||||
# },
|
||||
# "b_coord_radius": { "DESCRIPTION":"radius from earths dipole axis",
|
||||
# "DIMENSION": [1],
|
||||
# "UNITS": "R_E",
|
||||
# "START_COLUMN": 25
|
||||
# },
|
||||
# "b_coord_height": { "DESCRIPTION":"height above earths equatorial plane",
|
||||
# "DIMENSION": [1],
|
||||
# "UNITS": "R_E",
|
||||
# "START_COLUMN": 26
|
||||
# },
|
||||
# "magnetic_longitude": { "DESCRIPTION":"magnetic longitude",
|
||||
# "DIMENSION": [1],
|
||||
# "UNITS": "degrees",
|
||||
# "START_COLUMN": 27
|
||||
# },
|
||||
# "L_shell": { "DESCRIPTION":"L shell, dipole file, T89",
|
||||
# "DIMENSION": [1],
|
||||
# "UNITS": "R_E",
|
||||
# "START_COLUMN": 28
|
||||
# },
|
||||
# "bfield_ratio": { "DESCRIPTION":"Bsatellite/Bequator",
|
||||
# "DIMENSION": [1],
|
||||
# "UNITS": "none",
|
||||
# "START_COLUMN": 29
|
||||
# },
|
||||
# "local_time": { "DESCRIPTION":"Magnetic local time",
|
||||
# "DIMENSION": [1],
|
||||
# "UNITS": "h",
|
||||
# "START_COLUMN": 30
|
||||
# },
|
||||
# "b_sattelite": { "DESCRIPTION":" field at satellite",
|
||||
# "DIMENSION": [1],
|
||||
# "UNITS": "gauss",
|
||||
# "START_COLUMN": 31
|
||||
# },
|
||||
# "b_equator": { "DESCRIPTION":"B field at equator",
|
||||
# "DIMENSION": [1],
|
||||
# "UNITS": "gauss",
|
||||
# "START_COLUMN": 32
|
||||
# },
|
||||
# "diffp": { "DESCRIPTION":"not sure what this is",
|
||||
# "DIMENSION": [1],
|
||||
# "UNITS": "gauss",
|
||||
# "START_COLUMN": 33
|
||||
# },
|
||||
# "sigmap": { "DESCRIPTION":"not sure what this is",
|
||||
# "DIMENSION": [1],
|
||||
# "UNITS": "gauss",
|
||||
# "START_COLUMN": 34
|
||||
# },
|
||||
# "electron_background": { "DESCRIPTION":"electron_background estimated",
|
||||
# "DIMENSION": [8],
|
||||
# "UNITS": "hertz",
|
||||
# "START_COLUMN": 35
|
||||
# },
|
||||
# "proton_background": { "DESCRIPTION":"proton_background estimated",
|
||||
# "DIMENSION": [8],
|
||||
# "UNITS": "hertz",
|
||||
# "START_COLUMN": 43
|
||||
# },
|
||||
# "proton_activity": { "DESCRIPTION":"proton_activity=1 if proton activity is occurring",
|
||||
# "DIMENSION": [1],
|
||||
# "UNITS": "none",
|
||||
# "START_COLUMN": 51
|
||||
# },
|
||||
# "electron_temperature_fit": { "DESCRIPTION":"electron temperature from Maxwellian fit",
|
||||
# "DIMENSION": [1],
|
||||
# "UNITS": "MeV",
|
||||
# "START_COLUMN": 52
|
||||
# },
|
||||
# "electron_density_fit": { "DESCRIPTION":"electron number density fit",
|
||||
# "DIMENSION": [1],
|
||||
# "UNITS": "cm^-3",
|
||||
# "START_COLUMN": 53
|
||||
# },
|
||||
# "model_counts_electron_fit": { "DESCRIPTION":"E1-E8 rates from Maxwellian fit",
|
||||
# "DIMENSION": [8],
|
||||
# "UNITS": "hertz",
|
||||
# "START_COLUMN": 54
|
||||
# },
|
||||
# "dtc_counts_electron": { "DESCRIPTION":"E1-E8 rates dead time corrected",
|
||||
# "DIMENSION": [8],
|
||||
# "UNITS": "hertz",
|
||||
# "START_COLUMN": 62
|
||||
# },
|
||||
# "integral_flux_instrument": { "DESCRIPTION":"integral of electron flux fit above integral_flux_energy[i]",
|
||||
# "DIMENSION": [30],
|
||||
# "UNITS": "cm^-2sec^-1sr^-1",
|
||||
# "START_COLUMN": 70
|
||||
# },
|
||||
# "integral_flux_energy": { "DESCRIPTION":"energies for integral_flux_instrument",
|
||||
# "DIMENSION": [30],
|
||||
# "UNITS": "MeV",
|
||||
# "START_COLUMN": 100
|
||||
# },
|
||||
# "electron_diff_flux_energy": { "DESCRIPTION":"energies for the fluxes in electron_diff_flux_energy",
|
||||
# "DIMENSION": [15],
|
||||
# "UNITS": "MeV",
|
||||
# "START_COLUMN": 130
|
||||
# },
|
||||
# "electron_diff_flux": { "DESCRIPTION":"electron flux at energies electron_diff_flux[i]",
|
||||
# "DIMENSION": [15],
|
||||
# "UNITS": "cm^-2sec^-1sr^-1MeV^-1",
|
||||
# "START_COLUMN": 145
|
||||
# }
|
||||
# }')
|
||||
Reference in New Issue
Block a user