Area fill plot confidence interval

for this you need the three time series data sets , fill between values (above(y_upper_series) and below(ylow_serie values)) and the actual values(ysearies)

plt.figure()
plt.plot(xseries,yseries,color=’red’, linewidth=2,label=’test’,linestyle=’-‘,marker=’.’)

plt.fill_between(xmon,ylow_series,y_upper_series, alpha=0.4, edgecolor=’mediumorchid’, facecolor=’plum’)

more info
https://matplotlib.org/gallery/recipes/fill_between_alpha.html

https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.fill_between.html

 

test

 

exit from python program

go with the third method: sys.exit.

  1. quit raises the SystemExit exception behind the scenes.

    Furthermore, if you print it, it will give a message:

    >>> print (quit)
    Use quit() or Ctrl-Z plus Return to exit
    >>>

    This functionality was included to help people who do not know Python. After all, one of the most likely things a newbie will try to exit Python is typing in quit.

    Nevertheless, quit should not be used in production code. This is because it only works if the site module is loaded. Instead, this function should only be used in the interpreter.

  2. exit is an alias for quit (or vice-versa). They exist together simply to make Python more user-friendly.

    Furthermore, it too gives a message when printed:

    >>> print (exit)
    Use exit() or Ctrl-Z plus Return to exit
    >>>

    However, like quitexit is considered bad to use in production code and should be reserved for use in the interpreter. This is because it too relies on the site module.

  3. sys.exit raises the SystemExit exception in the background. This means that it is the same as quit and exit in that respect.

    Unlike those two however, sys.exit is considered good to use in production code. This is because the sys module will always be there.

  4. os._exit exits the program without calling cleanup handlers, flushing stdio buffers, etc. Thus, it is not a standard way to exit and should only be used in special cases. The most common of these is in the child process(es) created by os.fork.

    Note that, of the four methods given, only this one is unique in what it does.

Summed up, all four methods exit the program. However, the first two are considered bad to use in production code and the last is a non-standard, dirty way that is only used in special scenarios. So, if you want to exit a program normally, go with the third method: sys.exit.

https://stackoverflow.com/questions/19747371/python-exit-commands-why-so-many-and-when-should-each-be-used

change login shell

To finding the name of the current shell’s executable
echo $0
Or
ps -ef | grep $$ | grep -v grep

First, find out available shell list:
$ less /etc/shells

Try linux command chsh.

The detailed command is chsh -s /bin/bash. It will prompt you to enter your password. Your default login shell is /bin/bash now. You must log out and log back in to see this change.

The following is quoted from man page:

The chsh command changes the user login shell. This determines the name of the users initial login command. A normal user may only change the login shell for her own account, the superuser may change the login shell for any account

This command will change the default login shell permanently.

Note: If your user account is remote such as on Kerberos authentication (e.g. Enterprise RHEL) then you will not be able to use chsh.

https://www.cyberciti.biz/faq/howto-change-linux-unix-freebsd-login-shell/

To find out available shell list:
$ less /etc/shells

Sample Outputs:

/bin/ash
/bin/csh
/bin/sh
/usr/bin/es
/bin/ksh
/bin/tcsh
/bin/sash
/bin/zsh
/bin/dash
/usr/bin/screen
/bin/bash
/bin/rbash

Calculate RMSE ,R

For correlation coefficient you can directly use pearsonr function, for RMSE, you can defne a function as below

from scipy.stats.stats import pearsonr

##———– functions ————
def rmsef(predictions, targets):
return np.sqrt(((predictions – targets) ** 2).mean())

 

def averagef(arr, n):
end = n * int(len(arr)/n)
return np.mean(arr[:end].reshape(-1, n), 1)

rmse= rmsef(modlra,obsr)
corr = pearsonr(modlra,obsr)
corrC= corr[0]

write to csv python

import csv

myData = [[1, 2, 3], ['Good Morning', 'Good Evening', 'Good Afternoon']]  
myFile = open('csvexample3.csv', 'w')  
with myFile:  
   writer = csv.writer(myFile)
   writer.writerows(myData)
import csv
with open('eggs.csv', 'w', newline='') as csvfile:
    spamwriter = csv.writer(csvfile, delimiter=' ',
                            quotechar='|', quoting=csv.QUOTE_MINIMAL)
    spamwriter.writerow(['Spam'] * 5 + ['Baked Beans'])
    spamwriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam'])