-
Notifications
You must be signed in to change notification settings - Fork 0
/
atlas_rain_fix.py
executable file
·51 lines (41 loc) · 1.43 KB
/
atlas_rain_fix.py
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
50
51
#!/usr/bin/env python
"""
Script to alter a rain file. Alters the entire deployment.
Author: Daryn White, [email protected]
"""
import sys
import argparse
import tao.atlas.ram
import tao.util.calc
## Parse handed arguments
parser = argparse.ArgumentParser(
prog="atlas_rain_fix",
description="Simple script to alter a rain file. Alters the entire deployment.",
)
parser.add_argument("fl", metavar="file", help="RAM file for processing")
parser.add_argument("val", type=int, help="Offset volume of data by this amount")
parser.add_argument("A", type=int, help="Lowest value of original data")
parser.add_argument("B", type=int, help="Highest value of original data")
parser.add_argument("a", type=int, help="New value point for A")
parser.add_argument("b", type=int, help="New value point for B")
args = parser.parse_args()
# Load file
read = tao.atlas.ram.File(args.fl)
# Load frame
frame = read.frame
# Vars to work with
rain = frame.loc[:, ("RAIN", "-3")]
# Alter the polar direction values
altrain = rain.values + args.val
# scaling
rainFixed = (args.a + (altrain - args.A) * (args.b - args.a)) / (args.B - args.A)
# Update the frame
frame.loc[:, ("RAIN", "-3")] = rainFixed
# Write file with altered data
read.writeAtlas(frame, output=args.fl + "_fixed")
out = f"""
:: NEED TO ADD THIS TO FLAG FILE! ::
## Altered rain data by {args.val} ml and scaled {args.A} to {args.a} & {args.B} to {args.b}
BEGIN END Q3 1
"""
sys.stdout.write(out)