Thanks @rabernat.
I have one last question. I am trying to use both bash and python in one python script that I am going to do two things:
1: Copy files from one directory to another using a bash script named "COPY_FILES.sh. The copying of the files is done like this:
cp -r /home/FILES2/TOT_R."000"${day}.data /home/FILES1/REGIONS
2: Then open the copied files in /home/FILES1/REGIONS using xm.open_mdsdataset
3: Run the same script for multiple timesteps.
The code I wrote is the following :
for day in range(7730880,12987840,960):
output = subprocess.run(['bash', '/home/REGIONS/COPY_FILES.sh',str(ndays),str(day)])
datatot =xm.open_mdsdataset(data_dir='/home/FILES1/REGIONS',grid_dir='/home/grid/GRID_DATA',prefix=['TTc_R'],iters=[day],delta_t=90,read_grid=False,nx=1999,ny=1999,ref_date='1979-01-15 00:00',geometry='sphericalpolar')
dT_dt = datatot.TOTTEND2; dTnan=np.ma.array(dT_dt,mask=np.isnan(dT_dt))
I noticed that when I try to run the code in the loop of days and after the files are copied (step number 1) in the first 2 or 3 (loops) timesteps xm.open_mdsdataset doesn’t seem to be able to read the data properly and I get the following error:
AttributeError: 'Dataset' object has no attribute 'TOTTEND2'
After a while IF i am not in the loop and I let the script rest and then just run:
datatot =xm.open_mdsdataset(data_dir='/home/FILES1/REGIONS',grid_dir='/home/grid/GRID_DATA',prefix=['TTc_R'],iters=[day],delta_t=90,read_grid=False,nx=1999,ny=1999,ref_date='1979-01-15 00:00',geometry='sphericalpolar')
dT_dt = datatot.TOTTEND2; dTnan=np.ma.array(dT_dt,mask=np.isnan(dT_dt))
on its own then the files are read without a problem. Any ideas why this could happening? it seems that there is a lag in the response of xm.open_mdsdataset for some reason. Have you ever heard of this before?
Sofi