Skip to content

Commit

Permalink
Refreshed cgyrodb
Browse files Browse the repository at this point in the history
  • Loading branch information
jcandy committed Nov 4, 2024
1 parent 0f477e2 commit 023a7a1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
1 change: 0 additions & 1 deletion cgyro/bin/cgyro_converge
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import numpy as np
import os
import sys
import matplotlib as mpl
import matplotlib.pyplot as plt
import argparse
import textwrap
Expand Down
42 changes: 29 additions & 13 deletions cgyro/bin/cgyrodb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/usr/bin/env python

import os
import sys, getopt
import sys
import argparse
import textwrap
import numpy as np
import pandas as pd
from tqdm import tqdm
Expand All @@ -11,29 +13,44 @@ from cgyro.data import cgyrodata

pd.set_option('display.max_rows', None)

opts, args = getopt.getopt(sys.argv[1:],"hm:",[])
# Command line option parser
def opts():

if opts == []:
print('cgyrodb -m <mode>')
sys.exit(2)
mytext = '''\
output:
NEED DOCUMENTATION HERE
'''

for opt,arg in opts:
if opt == '-h' or opt == '':
print('cgyrodb -m <mode> with mode=[update,scan,flux]')
sys.exit()
elif opt == '-m':
mode = arg
parser = argparse.ArgumentParser(
formatter_class=argparse.RawTextHelpFormatter,
prog = 'cgyrodb',
description="CGYRO database utility",
epilog=textwrap.dedent(mytext))

parser.add_argument('-mode',
help='Mode switch (data,update)',
type=str,
default='data')

args=parser.parse_args()

return args.mode

mode = opts()

meta = {}

def gendict(sim,mode):

mydict = {}

mydict['n_n'] = sim.n_n
mydict['n_radial'] = sim.n_radial
mydict['n_theta'] = sim.n_theta
mydict['q'] = sim.q
mydict['s'] = sim.shear
mydict['kappa'] = sim.kappa
mydict['nuee'] = sim.nu[-1]
mydict['a/Ln0'] = sim.dlnndr[0]
mydict['a/Lt0'] = sim.dlntdr[0]
if sim.n_species > 1:
Expand Down Expand Up @@ -66,7 +83,6 @@ if mode == 'update':
# Run through directories and update
for mdir in y:
print('Updating '+mdir)
os.system('cgyro_plot -plot text -e '+mdir)
os.system('cgyro -t '+mdir)
else:
# Create master dictionary "meta"
Expand All @@ -75,5 +91,5 @@ else:
meta[mdir]=gendict(sim,mode)

df = pd.DataFrame(meta)
dfpart = df.T[['n_radial','n_theta','q','s','a/Ln0','a/Lt0','a/Ln1','a/Lt1']]
dfpart = df.T[['n_n','n_radial','n_theta','q','s','kappa','a/Ln0','a/Lt0','a/Ln1','a/Lt1','nuee']]
print(dfpart)

0 comments on commit 023a7a1

Please sign in to comment.