background preloader

Science

Facebook Twitter

SciPy - Cookbook/Interpolation - Example showing how to use B-splines in scipy.signal to do interpolation. The input points must be equally spaced to use these routine. from numpy import r_ , sin from scipy . signal import cspline1d , cspline1d_eval x = r_ [ 0 : 10 ] dx = x [ 1 ] - x [ 0 ] newx = r_ [ - 3 : 13 : 0.1 ] y = sin ( x ) cj = cspline1d ( y ) newy = cspline1d_eval ( cj , newx , dx = dx , x0 = x [ 0 ] ) from pylab import plot , show plot ( newx , newy , x , y , 'o' ) show ( ) The scipy.ndimage package also contains spline_filter and map_coordinates which can be used to perform N-dimensional interpolation for equally-spaced data.

A two-dimensional example is given below: To pre-compute the weights (for multiple interpolation results), you would use coeffs = ndimage . spline_filter ( fvals ) newf = ndimage . map_coordinates ( coeffs , coords , prefilter = False ) The scipy.interpolate packages wraps the netlib FITPACK routines (Dierckx) for calculating smoothing splines for various kinds of data and geometries. Interpolation (scipy.interpolate) — SciPy v0.11.dev Reference Guide. There are several general interpolation facilities available in SciPy, for data in 1, 2, and higher dimensions: Multivariate data interpolation (griddata) Suppose you have multidimensional data, for instance for an underlying function f(x, y) you only know the values at points (x[i], y[i]) that do not form a regular grid. Suppose we want to interpolate the 2-D function >>> def func(x, y):>>> return x*(1-x)*np.cos(4*np.pi*x) * np.sin(4*np.pi*y**2)**2 on a grid in [0, 1]x[0, 1] >>> grid_x, grid_y = np.mgrid[0:1:100j, 0:1:200j] but we only know its values at 1000 data points: >>> points = np.random.rand(1000, 2)>>> values = func(points[:,0], points[:,1]) This can be done with griddata – below we try out all of the interpolation methods: >>> from scipy.interpolate import griddata>>> grid_z0 = griddata(points, values, (grid_x, grid_y), method='nearest')>>> grid_z1 = griddata(points, values, (grid_x, grid_y), method='linear')>>> grid_z2 = griddata(points, values, (grid_x, grid_y), method='cubic')

Interpolate.splrep — SciPy v0.11.dev Reference Guide. Interpolate.UnivariateSpline — SciPy v0.11.dev Reference Guide. Scientific Analysis in Python. Python based scientific analysis cookbook James Battat Created: October 3, 2006 Last Modified: July 12, 2010 I find Python very user-friendly. Therefore I often reach for it when tasked to solve small or large scripting problems. I have been rather frustrated, though, with the level of support for scientific analysis packages. With scipy and matplotlib, of course, the tools are all there and success is just around the corner... But if you're like me and you're at a loss when trying to do something in Python because you're used to using other languages (IDL) for scientific analysis then you may find this page useful. I do not explain how to obtain or install or debug scipy or matplotlib but i do list several useful tasks that frequently surface when doing science on a computer.

Without further ado, here we go. Load scipy and matplotlib (all future code assumes that you have taken this step) import scipy import pylab Get help on a scipy or matplotlib routine help(pylab.hist) Next header. GSL - GNU Scientific Library. Introduction The GNU Scientific Library (GSL) is a numerical library for C and C++ programmers. It is free software under the GNU General Public License. The library provides a wide range of mathematical routines such as random number generators, special functions and least-squares fitting.

There are over 1000 functions in total with an extensive test suite. The complete range of subject areas covered by the library includes, Unlike the licenses of proprietary numerical libraries the license of GSL does not restrict scientific cooperation. Downloading GSL The current version is GSL-1.16. GSL can be found in the gsl subdirectory on your nearest GNU mirror Main GNU ftp site: For other ways to obtain GSL, please read How to get GNU Software Installation instructions can be found in the included README and INSTALL files. Precompiled binary packages are included in most GNU/Linux distributions. Documentation Supported Platforms Mailing Lists. OpenLDAP, Main Page. Celestia: Home. Stellarium. Octave. GNU Octave is a high-level interpreted language, primarily intended for numerical computations.

It provides capabilities for the numerical solution of linear and nonlinear problems, and for performing other numerical experiments. It also provides extensive graphics capabilities for data visualization and manipulation. Octave is normally used through its interactive command line interface, but it can also be used to write non-interactive programs. The Octave language is quite similar to Matlab so that most programs are easily portable. Octave is distributed under the terms of the GNU General Public License. Version 4.0.0 has been released and is now available for download. An official Windows binary installer is also available from Thanks to the many people who contributed to this release! Maxima, a Computer Algebra System. Maxima Overview. Burkhard Bunk 19.3.2013 Maxima version: 5.21.1 wxMaxima version: 0.8.5 Documentation /usr/share/doc/maxima-doc/html/intromax.html introduction /usr/share/doc/maxima-doc/html/maxima_toc.html full help Invocation, Help Text mode: unix> maxima interrupt a maxima calculation with <CTRL>-G terminate maxima with quit(); GUI: unix> xmaxima unix> wxmaxima Help: GUI ->Help descripe(string); ?

A perfect way to restart maxima does not exist (see mailing list), use reset(); kill(all); Commands and Expressions Terminate commands with ";" or "$" (quiet mode). command prompts: (%i1) (%i2) .. output labels: (%o1) (%o2) .. Names Names consist of letters, digits, % (percent) and _ (underscore). Declare("$", alphabetic); Pre-defined constants: %i %pi %e true false %gamma Euler's constant %phi (1 + sqrt(5))/2 inf real infinity minf real (-infinity) infinity complex infinity Pre-defined functions: sqrt log exp sin .. asin .. sinh .. asinh .. gamma zeta binomial mod floor ..

Reserved names: Assignment Lists Evaluation. MKL - Research Computing (The University of Manchester) Overview MKL (Math Kernel Library) is a library of mathematical routines developed by intel for its processors. The library includes: BLAS (Basic Linear Algebra Subprograms) Sparse BLAS C and Fortran 95 interfaces to the BLAS LAPACK (Linear Algebra Package) Fortran 95 Interface to LAPACK FFTs (Fast Fourier Transforms) and DFTs (Discrete Fourier Transforms) Vector Math Library (VML) - core functions with vector arguments.

Vector Statistical Library (VSL) - random number generators. GNU Multi Precision (GMP) - arbitrary precision arithmetic on integers. Restrictions on Use There are no restrictions on use. Set Up Procedure To gain access to the libraries you need to load one of the MKL modules. Using the Library To use MKL you will need to link the library at link time. These are all dynamic libraries except mkl_solver , which contains sparse solver functions. Replace -lmkl_lapack64 with -lmkl_lapack32 for single precision. To link to Cluster DFT use: -lmkl_dft_cluster -lmkl Examples Using LAPACK bash$ . Math Kernel Library - Purchase. Welcome - OpenOpt. Finite-difference time-domain method. Finite-difference time-domain (FDTD) is a numerical analysis technique used for modeling computational electrodynamics (finding approximate solutions to the associated system of differential equations).

Since it is a time-domain method, FDTD solutions can cover a wide frequency range with a single simulation run, and treat nonlinear material properties in a natural way. The FDTD method belongs in the general class of grid-based differential numerical modeling methods (finite difference methods). The time-dependent Maxwell's equations (in partial differential form) are discretized using central-difference approximations to the space and time partial derivatives. History[edit] Development of FDTD and Maxwell's equations[edit] An appreciation of the basis, technical development, and possible future of FDTD numerical techniques for Maxwell’s equations can be developed by first considering their history. FDTD models and methods[edit] The H-field is time-stepped in a similar manner.

Meep - AbInitio. From AbInitio Meep (or MEEP) is a free finite-difference time-domain (FDTD) simulation software package developed at MIT to model electromagnetic systems, along with our MPB eigenmode package. Its features include: Free software under the GNU GPL. Simulation in 1d, 2d, 3d, and cylindrical coordinates. Meep officially stands for MIT Electromagnetic Equation Propagation, but we also have several unofficial meanings of the acronym. Time-domain simulation A time-domain electromagnetic simulation simply takes Maxwell's equations and evolves them over time within some finite computational region, essentially performing a kind of numerical experiment. Transmission and reflection spectra — by Fourier-transforming the response to a short pulse, a single simulation can yield the scattering amplitudes over a wide spectrum of frequencies.

Using these results, one can then compute many other things, such as the local density of states (from the trace of the Green's function). Download Documentation. Electromagnetic Template Library (EMTL) [E M T L] Is a С++ library for programming Finite-Difference Time-Domain (FDTD) simulations. The program is designed for quick and efficient programming of FDTD simulations and for extending the available FDTD algorithms with new techniques and features. The code implements fully functional API including MPI parallelization. Capabilities Calculation of the distribution of electromagnetic fields in a structure;Real-time simulation of the propagation of electromagnetic wave packet through a structure;Calculation of the transmission, reflection, and absorption coefficients as functions of incident wavelength and angle for periodic structures;Calculation of the scattering cross-section and the angle distribution of the scattered wave for objects of arbitrary shape;Sensitivity analysis of the impact of defects on the optical properties of periodic structures (photonic crystals);Calculation of transfer-matrix (T-matrix) for planar layers of arbitrarily shaped scatterers; How to start using EMTL?

JFEM: Finite-Element Method (FEM) Codes. NETGEN. 3D FDTD code. Angora: A free finite-difference time-domain (FDTD) electromagnetic simulation package. RadarFDTD. Www.cemtach.com. Lomm | MOLED. CAMFR. Research Area: Design and Modeling for Integrated Photonics Main Researcher: Peter Bienstman We developped CAMFR, a comprehensive modelling tool for photonic components, which is freely available from sourceforge. CAMFR (CAvity Modelling FRamework) is a fast, flexible, friendly full-vectorial Maxwell solver. Although it can tackle general electromagnetic problems, its main focus is on applications in the field of photonics, like wavelength-scale microstructures (like photonic crystal devices)lasers (like vertical-cavity surface-emitting lasers)light-emitting diodes (like resonant-cavity LEDs) While other methods (like e.g.

Additionally, it can incorporate advanced boundary conditions (like e.g. The scattering matrix of a structurethe field inside a structure, for any given excitationband diagrams of an infinite periodic structurethreshold material gain and resonance wavelength of laser modesthe response to a current source in an arbitrary cavity Calculated field profiles in an airpost VCSEL.

Sage 4.3.5, mRCWA et CAMFR sur effix.sciences.univ-metz.fr. What is GNU Fortran? - Using and Porting GNU Fortran. GNU Fortran, or g77, is designed initially as a free replacement for, or alternative to, the UNIX f77 command. (Similarly, gcc is designed as a replacement for the UNIX cc command.) g77 also is designed to fit in well with the other fine GNU compilers and tools. Sometimes these design goals conflict—in such cases, resolution often is made in favor of fitting in well with Project GNU. These cases are usually identified in the appropriate sections of this manual. As compilers, g77, gcc, and f77 share the following characteristics: They read a user's program, stored in a file and containing instructions written in the appropriate language (Fortran, C, and so on). This file contains source code. How these actions are performed is generally under the control of the user. g77 consists of several components: A modified version of the gcc command, which also might be installed as the system's cc command.

Gcc is often thought of as “the C compiler” only, but it does more than that. Drives in line. Linux - What is libg2c library. CAMFR manual v1.3: 2.3 Putting a current source inside a cavity. This section illustrates how we can put a current source inside a cavity. This can be useful either to calculate the Green's function of a cavity, or the calculate the modification of spontaneous emission in resonant-cavity LEDs. As a first example, we calculate the modification of spontaneous emission of a horizontal current dipole placed between two parallel metallic plates.

This 3D planar open geometry is converted to a 3D closed cylindrical geometry by using PMLs (fig 2.3). Since this configuration can also be calculated analytically, we can easily verify the results. This script introduces a couple of new features. First of all set_circ_field_type(), which is only relevant for these kind of source problems, indicates whether the generated fields have cos or sin type angular dependence.

For calculating scattering matrices, these are completely decoupled, but for source problems, which one of these field types is excited is determined by the orientation of the current source. CAMFR Home Page. CAMFR - Support. Extended version of CAMFR Planar 1D example to include absolute electric field and Poynting vector profiles. w4sni. Sage: Open Source Mathematics Software. Mrcwa - Multilayer Rigorous Coupled Wave Analysis. RODIS. Adventures in political engineering. Optics InfoBase - Stable implementation of the rigorous coupled-wave analysis for surface-relief gratings: enhanced transmittance matrix approach.

An enhanced, numerically stable transmittance matrix approach is developed and is applied to the implementation of the rigorous coupled-wave analysis for surface-relief and multilevel gratings. The enhanced approach is shown to produce numerically stable results for excessively deep multilevel surface-relief dielectric gratings. The nature of the numerical instability for the classic transmission matrix approach in the presence of evanescent fields is determined. The finite precision of the numerical representation on digital computers results in insufficient accuracy in numerically representing the elements produced by inverting an ill-conditioned transmission matrix.

These inaccuracies will result in numerical instability in the calculations for successive field matching between the layers. The new technique that we present anticipates and preempts these potential numerical problems. . © 1995 Optical Society of America. Mrcwa – Multilayer Rigorous Coupled Wave Analysis with Python and FORTRAN « Adventures in political engineering. Mrcwa implements the rigorous coupled-wave analysis (RCWA) algorithm for grating diffraction.

The computational engine is written in FORTRAN and utilizes the high performance linear algebra package LAPACK, and Python language bindings are provided. Here is the machine_cfg.py that I used to compile it on my MacBook Pro: I used the gfortran that was installed by the SciPy Superpack. The libraries /usr/lib/liblapack.dylib and /usr/lib/libblas.dylib are symlinked to the corresponding libraries in Apple’s Accelerate framework, at least on my MBP. Most of the provided examples execute in a reasonable amount of time (~[minutes]), but the superhydrophobic-grating example took about 20 hours to complete on my MBP, so consider yourself forewarned. Like this: Like Loading... Optical Propagation Software using EigenMode Expansion (EME) - FIMMPROP. Home.