0
Hello.. I have a python script that plots two different graphs and that needs to be run daily to update these graphs on a website
The data that is used by this script, is in a certain directory in HDF format
I created a Bash script that copies the data of this directory, converts to Netcdf, pastes in another directory, executes this script in python and updates the Graphics on the site
As I said, I need these graphics to be updated daily on the site, so I programmed this bash script to be run daily by crontab
crontab is actually running bash script: The data is being copied, converted and pasted...the python script is running and filling the Graphics so one of them, is coming with problem
In one of the Graphics ( what plots the orbit of a satellite), I need to place the initial and final time of data colteta
Something like that:
Start: 00:00:38 UTC
End: 01:29:57 UTC
SOH QUE ...when run by crontab, what is being plotted is this:
Start: 0 UTC
End: 4 UTC
If I turn manually, it works perfectly, and plots the hours the right way
That’s the part of my python script that’s filling the hours:
def cal_protime2dt(time):
d = int(time % 100)
m = int((time-d) % 10000)
y = int(time-m-d)
return dt.datetime(2000 + y//10000, m//100, d) + dt.timedelta(time % 1)
dates = [cal_protime2dt(time[i]) for i in np.arange(len(time))]
datestr = [i.strftime('%H:%M:%S') for i in dates]
t1=str(datestr[0])
t2=str(datestr[-1])
x, y = m(longitude[0], latitude[0])
m.plot(x, y, marker='D', color='m', markersize=2.1)
plt.text(-95,94.5, 'Start: {:} UTC \n\n\n '.format(t1), fontsize=5.55, color='m', ha='right',va='center')#, bbox=dict(facecolor='w', alpha=0.2))
z, w = m(longitude[-1], latitude[-1])
m.plot(z, w, marker='D', color='b', markersize=2.1)
plt.text(-97, 94.5, ' End: {:} UTC '.format(t2), fontsize=5.55, color='b',ha='right',va='center')
This is my bash script:
#!/bin/bash
ontem=$(date --date="2 days ago" +"%Y-%m-%d");
date=$ontem
year=`date +"%Y"`
previous_year=`date +"%Y" -d "-1 year"`
h4=/mnt/raid/CALIPSO/SCRIPTS/
dir=/mnt/raid/CALIPSO/DATA/NETCDF_TEMP/
cd /mnt/raid/CALIPSO/DATA/L1.5/2017/
cp CAL_LID_L15_Exp-Beta-V3-40.${date}T*.hdf /mnt/raid/CALIPSO/DATA/NETCDF_TEMP
for i in ${dir}*.hdf; do ${h4}h4tonccf_nc4 $i; done
python ${h4}CalipsoLatLonTimeLoop_TimTrack.py
rsync -u -z -v -e "ssh -p 8222" /mnt/raid/CALIPSO/PICS/${year}* [email protected]:/home/www/html/rt/PICS/${year}/
rsync -u -z -v -e "ssh -p 8222" /mnt/raid/CALIPSO/PICS/${previous_year}* [email protected]:/home/www/html/rt/PICS/${previous_year}/
And this is the way I programmed the crontab to run:
0 9 * * * /mnt/raid/CALIPSO/SCRIPTS/copy_convert_plot_update_twodaysago.sh
Does anyone have any idea what might be going on?
Hello! Thank you! But I think that was not the problem... I managed to solve.... The problem was in the part of the code where I was calculating the hours... I moved it around, and it started working again!
– Luana