Recent Changes · Search:

Dispense


µSR

Chapters:

  1. Introduction
  2. The muon
  3. Muon production
  4. Spin polarization
  5. Detect the µ spin
  6. Implantation
  7. Paramagnetic species
  8. A special case: a muon with few nuclei
  9. Magnetic materials
  10. Relaxation functions
  11. Superconductors
  12. Mujpy
  13. Mulab
  14. Musite?
  15. More details

Tips

PmWiki

pmwiki.org

edit SideBar

Python

< ASE initial trial | Index | PyMinuit, how to install and use it >


Building a function, matlab style (see /homerdr/ipython/ eg_function.py, fib.py)

A module is a file containing Python definitions and statements

If it contains a list of commands it is like a script
If it contains a function it works as a matlab function file.

The equivalent of

  function [out]=fctname(in)
  ....
  out=...

is

  def fctname(in):
    .... # notice the indent
    return out

and it does not require to be stored in a file of the same name, e.g. store it in casual.py To run fctname

  IN=...
  import casual as cs
  cs.fctname(IN)

When writing and correcting use reload, e.g. if you imported fb, reload(fb)

Write documentation within two """, use line feeds and indents, to read formatted documentation use

  print module.function.__doc__

< ASE initial trial | Index | PyMinuit, how to install and use it >

Edit - History - Print - PDF - Recent Changes - Search
Page last modified on January 18, 2011, at 03:10 PM