Skip to content

Commit

Permalink
Command-line time-averaging function
Browse files Browse the repository at this point in the history
  • Loading branch information
jcandy committed Sep 13, 2024
1 parent c2d5e58 commit c910b8f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
34 changes: 34 additions & 0 deletions cgyro/bin/cgyro_converge
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env python

import numpy as np

from pygacode.cgyro import data
from pygacode.gacodefuncs import *

# read minimal data for setup
sim = data.cgyrodata('./',fast=True,silent=True)

t = sim.t
ns = sim.n_species

# read bin.cgyro.ky_flux
sim.getflux()

# select field=0,moment=1, and sum over kx
field=0 ; moment=1
y = np.sum(sim.ky_flux[:,moment,field,:,:],axis=1)

# averaging (note that time_average function is fast/optimized)
w='0.5'
imin,imax=time_index(t,w)
for ispec in range(ns):
ave = time_average(y[ispec,:],t,imin,imax)
print(ave)

w='0.75'
imin,imax=time_index(t,w)
for ispec in range(ns):
ave = time_average(y[ispec,:],t,imin,imax)
print(ave)


4 changes: 2 additions & 2 deletions f2py/pygacode/cgyro/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
class cgyrodata:

# constructor reads in basic (not all) simulation data
def __init__(self,sim_directory,silent=False):
def __init__(self,sim_directory,silent=False,fast=False):

self.silent = silent
self.dir = sim_directory
hastime = self.gettime()
self.getgrid()
if hastime:
if hastime and not fast:
self.getdata()

# standard routine to read binary or ASCII data
Expand Down

0 comments on commit c910b8f

Please sign in to comment.