#!/usr/bin/env python
# coding: utf-8
#
# Patrick BROCKMANN - LSCE (Climate and Environment Sciences Laboratory)
#
#
# Updated: 2019/11/13
# #### Install the ferret extension
# ferretmagic extension is now a package you can install from pip
#
# `pip install ferretmagic`
#
# https://pypi.python.org/pypi/ferretmagic
# #### then load the extension
# In[1]:
get_ipython().run_line_magic('load_ext', 'ferretmagic')
# #### Now use extension magic cell (%%ferret) or magic line (%ferret_run)
# In[2]:
get_ipython().run_cell_magic('ferret', '', 'use levitus_climatology\nshow grid temp\nlet a=12\n')
# In[3]:
get_ipython().run_cell_magic('ferret', '', 'list a\nshow data\nplot i[i=1:10]\n')
# #### Usage and current options
# * Control size of plot with option --size, -s width, heigh
# * Create a local pdf at the same time with option --pdf, -p
# * Do not display stdout with option --quiet, -q
#
# Discover usage by typing
# %ferret_run?
# #### Plot are imbedded into directly into the notebook
# In[4]:
get_ipython().run_cell_magic('ferret', '-b -q -s 800,600', 'shade/lev=15 temp[k=@std]\ngo land\ngo text_put 50 50 "aaaa" 0 2\n')
# #### You can execute ferret commands from python with the line magic %ferret_run
# In[5]:
for i in range(1,10,2):
get_ipython().run_line_magic('ferret_run', "-q -s 300,300 'shade temp[k=%(i)s] ; go land' % locals()")
# In[6]:
def draw(i):
get_ipython().run_line_magic('ferret_run', "-q -s 300,300 'shade temp[k=%d] ; go land' % i")
print("%d" % (i))
draw(2)
# In[7]:
for i in [100,500,1000]:
get_ipython().run_line_magic('ferret_run', "-b -s 300,300 'plot sin(i[i=1:%(i)s]*0.1)' % locals()")
# #### Display helps
# In[8]:
get_ipython().run_line_magic('pinfo', '%%ferret')
# In[9]:
get_ipython().run_line_magic('pinfo', '%ferret_run')
# In[10]:
get_ipython().run_cell_magic('ferret', '', 'show symb\n')