--- layout: default title: "How To Receive All Your Email During The Server Move" author: name: Jon Cram url: http://webignition.net ---
I mentioned recently our plans to move to new hosting servers.
I stated in a related email announcement that no mail will be lost as mail ending up at one of the old servers will be routed automatically to the relevant new server. This is still true and your email will not get lost.
Whilst no email will be lost (I've spent the last two days testing out various scenarios), you might think some email as gone astray as you may be looking in the wrong place for your email when you think you're looking in the right place.
Here's how you can ensure no interruptions occur to your email service during the move.
If you use Hosting Reborn for your email, both your incoming and outgoing mail servers should be set to either your domain or your mail subdomain.
For me, that would be either hostingreborn.com or mail.hostingreborn.com. For you, replace hostingreborn.com with the domain name in your email address.
If you are using any other server name for your incoming or outgoing mail server, it is working but conincidence not by design. Unless, of course, you're intentionally using another mail service and know what you're doing.
Check your mail client's server settings now. If either the incoming or outgoing mail server address is anything other than the domain name in your email address (optionally preceded by mail.) and you're not using a third-party mail service, change your settings now.
Please contact us if you're in doubt.
After your own hosting accounts have been moved I will send you an email directly detailing what you need to do or look out for.
You may not get that email straight away if you're looking in the wrong place for email when you think you're looking in the right place.
Here's what you need to look out for when it comes to email to be sure that you get the email that we send you.
At present, the global DNS system tells your computer to look on the current (soon to be old) Hosting Reborn servers when you want to receive new messages.
Immediately after the move, the global DNS system will know no different. Although we will update your DNS records to indicate that your email now lives on the new Hosting Reborn servers, it will take some time for every Internet service to notice the change.
This is how you may end up looking in the wrong place for your email when you think you're looking in the right place.
Eventually things will sort themselves out and after a few hours or perhaps a day (it really depends on your Internet provider) but during this time you may not be receiving any new emails as all new emails will be patiently waiting on the new servers whilst you're looking on the old servers.
If you think you're not receiving new messages immediately after the move, you may need to tell your email client to look directly on the new Hosting Reborn servers (instead of letting the global DNS system figure this out for you).
In this respect you've got two options. The first is for advanced users, the second is for everyone else:
Set up a local hosts file entry mapping your incoming mail server hostname to <IP_ADDRESS>. I am intentionally not going to explain that. If that makes no sense it is not the option for you.
Make a note of your current incoming mail server address and change it to <IP_ADDRESS>. A couple of days later you can change it back to what it was. This is likely your best option.
There is actually a third option: do nothing. Things will sort themselves out eventually. Your email will not be lost, just waiting.
Please contact us if you have any concerns about your email immediately after your hosting accounts have been moved.
If you need to do so, make sure to remember something very important: if you are having problems receiving email and you get in touch using the very same email address, you may not receive our replies.
If you do need to get in touch about your email after your hosting accounts have been moved, please use an email address not hosted by us so that we can be sure you will receive our replies. You can easily get a free GMail address which would be fine.


UTC +3
Voltage: 220/230 V
Frequency: 50 Hz
The local currency is the Yemeni rial. The exchange rate is stable at 215 YER for 1USD.
US dollars is the best currency to carry.
International Dialing Code is +967
Yemen City Area Telephone Codes
+ 967 1 Sanaa
+ 967 3 al-Hudaydah
+ 967 5 al- Mukalla
Yemen Mobile Telephone Codes/Operators
Sabafon Yemen +967 71
SpaceTel Yemen +967 73
A Yemen prepaid SIM card with a GSM international cell phone is an affordable solution for staying in touch while in Yemen. All incoming calls, while in Yemen are FREE, regardless of where they originate. Pay the local rate for local calls and use a cellular phone in Yemen like you do at home. And unlike home, your Yemen SIM card and cell phone service is prepaid so there is no need for a contract.
Emergency - Dial 199
IMRAY AND ADLARD COLES PILOT BOOKS are aAvailable at a discounted price for Noonsite.com users via World Cruising Club
Red Sea Pilot: Aden to Cyprus (Mediterranean pilots & charts)
By Elaine Morgan & Stephen Davies
Publisher: Imray,Laurie,Norie & Wilson Ltd; 2nd Revised edition (December 2002)
ISBN-13:<PHONE_NUMBER>543
This fully revised 2nd ed. pilot covers the entire stretch of the Red Sea from Aden to Cyprus. Including ports and anchorages on the Red Sea coasts of Oman, Yemen, Aden, Djibouti, Eritrea, Sudan, Saudi Arabia, Egypt, the Gulf of Aqaba, the Suez Canal, Israel and Cyprus. Over 70 anchorages were resurveyed and new ones explored. One key improvement is the coverage of diving sites.
Tamarisk - Round the World
http://www.tamariskrtw.com/
Three years into a circumnavigation that began in Turkey, January 2015 sees SY Tamarisk on passage up the Red Sea, via the Gulf of Aden, Saudi Arabia, Sudan and upwards towards the Suez Canal.
Noonsite welcomes information and updates especially regarding clearance, customs and immigration procedures from cruisers visiting this country.
Please E-mail noonsite with any new information, updates or corrections. Even just a short email confirming that the current data is accurate would be most helpful.


wewadasd 41412 543543 Share with 12 people: chen pengfei Comments 22 hours ago 22 hours ago 22 hours ago 22 hours ago


Simple HTML Editor
This example...
- Uses bootstrap (tooltips, dropdowns, modal dialog)
- Uses bootbox for bootstrap modals
- Uses bootstrap-colorpicker
- Uses font-awesome icons
- Adds more common buttons to the toolbar (format, font, super/sub-script, table, fore/back-color)
- Improves support for hyperlinks
- Prettyfies the image upload button
- Makes the editor resizable (in supported browsers)
Submit


Programming Assignment 1 Review
Dealing with Missing Data
Visualizing Data
Combining and Transforming Data Frames
Final Project Discussion
IMHO, this assignment was the single hardest thing you'll be asked to do in this class.
NA
is a special object in R, used to capture the idea of "a value whose value is unknown". Confusing, right? They're an inevitability in real-world data.
PRO TIP: See ?NA
for R's documentation on the nuances of NA
# Create a vector w/ missing data
some_nums <- c(1,2,NA, 6, NA, 8)
print(some_nums)
## [1] 1 2 NA 6 NA 8
# Use is.na() to get a vector of TRUE/FALSE for the question "is this element NA?"
is.na(some_nums)
## [1] FALSE FALSE TRUE FALSE TRUE FALSE
# Confirm that even w/ NAs, R still knows this is a numeric vector
class(some_nums)
## [1] "numeric"
It's common for introductory programmers to think of missing values as problems to address, but that isn't always the case! NA
can actually hold valuable information. For example, imagine that you get a dump of data from Salesforce or some other CRM system with information like customer_name, date_of_first_contact, and date_of_second_contact.
Depending on how the system was set up, date_of_second_contact1
may have dates only for customers who have been contacted at least twice, and be NA
everywhere else. This is valuable information! If you want to build a model of 1-contact conversion, you could use the presence/absence of NA
to help you identify the 1-contact customers that belong in your model.
The first approach you may take to dealing with NA
values is to simply drop them from your data. If you don't think these missing data have any business value and your dataset is big enough that you can afford to drop some rows / columns, this is the right move for you.
# Removing NAs for vectors
top5 <- c("Wale", "Chance", NA, "Lupe Fiasco", "Shad", "Kanye", NA)
print(top5)
top5cleaned <- top5[!is.na(top5)]
print(top5cleaned)
# Removing rows with ANY NAs for data.frames
myDF <- data.frame(x = c(1, 2, NA, 4), y = c(NA, TRUE, FALSE, TRUE),
z = c("hey", "there", NA, "friends"))
cleanDF <- myDF[complete.cases(myDF), ]
You may find the "remove all the NAs everywhere" strategy a bit too aggressive for your use case. If you have a 100-variable dataset and a single variable (column) is 90\% NA values, do you really want to drop every row where that variable is NA? A better approach might be to selectively subset out columns where missing values are most severe before using complete.cases()
to remove rows.
# Create a data frame where some variable have more NAs than others
testDF <- data.frame(var1 = sample(c(rnorm(99), NA), 200, replace = TRUE),
var2 = sample(c(rnorm(50), rep(NA, 50)), 200, replace = TRUE),
var3 = sample(c(rnorm(5), rep(NA, 95)), 200, replace = TRUE))
# Find columns that are more than 90% missing values
.percent_na <- function(a_vector){return(sum(is.na(a_vector)/length(a_vector)))}
colsToDrop <- apply(testDF, MARGIN = 2, .percent_na) > 0.9
cleanDF <- testDF[, !colsToDrop]
# Remove rows w/ remaining NAs
cleanDF <- cleanDF[complete.cases(cleanDF),]
A final strategy, particularly useful in modeling contexts, is to use some imputation strategy to replace NA
values with reasonable alternatives. One common approach (and my favorite), the roughfix
method. It works like this:
# Create a data frame where some variable have more NAs than others
testDF <- data.frame(var1 = sample(c(rnorm(99), NA), 500, replace = TRUE),
var2 = sample(c(rnorm(70), rep(NA, 30)), 500, replace = TRUE),
var3 = sample(c(rnorm(85), rep(NA, 15)), 500, replace = TRUE))
# Clean up w/ roughfix
library(randomForest)
cleanDF <- randomForest::na.roughfix(testDF)
R's built-in plotting tools, called "the base plotting system", is one of its most popular features.
The essential idea of the base plotting system is to build up plots in layers. You first create a simple plot, then "add on" a legend, more variables, other plot types, etc.
See "The Base Plotting System" in the programming supplement.
Let's start with a simple scatter plot to answer the question are sepal length and sepal width related?
See "The Base Plotting System" in the programming supplement.
Histograms and densities are useful for examining distributions.
See "The Base Plotting System" in the programming supplement.
You can add more than one variable to these plots!
You can combine multiple plots in a grid layout. See "The Base Plotting System" for an example.
We don't have time in this short class to go into great depth on data visualization, but I want you to know that there are a bunch of cool visualization libraries a short install.packages()
away!
When R (or any other program!) creates plots, it needs to know where to put them! When you call plot()
or other commands from within and RStudio session, the default is to just display the resulting figure in the "Plots" pane. However, you can use other graphics devices (places to put visual output) to tell R to put your figures elsewhere.
In situations where you have multiple data frames with the same rows but different columns, you can combine them column-wise with R's cbind()
command. Note that this command will only work if the two data frames to be joined have the same number of rows AND those rows refer to the same observation.
cbind = "column-wise bind"
It's common in data science workflows to have two mismatched tables of data from different sources and to want to combine them by matching on one or more keys. Think JOIN
in SQL or VLOOKUP
in Excel. To perform this operation in R, you can use the merge()
command.
So far we've talked about merging columns from different tables. But what if you want to merge rows? For example, imagine that you are a researcher in a lab studying some natural phenomenon. You may take multiple samples (measuring the same variables) and then want to put them together into a single data frame to build a model. For this case, we can use R's rbind()
function.
rbind = "row-wise bind"
What if you have 5 tables? 10? 1000? Use data.table::rbindlist()
.
Choosing External Packages
What Your Proposal Should Cover
Plotting in R: graphics devices
Paths: Relative vs absolute | listing files in a directory in R


LOOKING FOR RICHARD A film review by Mark R. Leeper Copyright 1996 Mark R. Leeper
Capsule: LOOKING FOR RICHARD is so ambitious that it works better as a partial failure than most films do that are successes. This is a pseudo- documentary about the making of what I take to be a non-existent film adaptation of Shakespeare's RICHARD III and the discussions of the material as the actors prepare. There is the discussion of Shakespeare and of RICHARD III, interspersed with seeing how the actors actually do the scenes. LOOKING FOR RICHARD makes an engrossing companion piece to last year's wonderful film production of RICHARD III with Ian McKellen. The discussion opens up the play RICHARD III and indeed all of Shakespeare and gives us an unparalleled behind- the-scenes look at the actors' craft. Director and star Al Pacino falls down only in being a bit to self-indulgent and in allowing this to become a vanity piece with too many diversions into arguments and clowning around on and off set. Rating: high +1 (-4 to +4)
With a remarkable number of Shakespeare plays being made into films recently, LOOKING FOR RICHARD, directed, co-produced, and co- written by Al Pacino, could not have been more timely. There have been many films about the activity of making films, but to my knowledge this is the first film about the making of a Shakespeare film. It gives real insight into the richness and complexity of Shakespeare's writing as well as into the filmmaking process. Pacino's film seamlessly bounces between real documentary and scenes of the fictitious production of an all-star version of RICHARD III. Meanwhile not just the actors in the supposed film (Al Pacino, Harris Yulin, Penelope Allen, Alec Baldwin, Kevin Spacey, Estelle Parsons, Winona Ryder, and Aiden Quinn), but also guests not in the film--like Kenneth Branagh, Kevin Kline, James Earl Jones, Rosemary Harris, Peter Brook, Derek Jacobi, John Gielgud, and Vanessa Redgrave--talk about the content of Shakespeare and the art of acting Shakespeare. To have all these people in one film is remarkable in itself. To get them all talking about a subject like Shakespeare is wonderful. To then waste so much time watching Pacino clown around as much as he does is agonizing. Indeed, Pacino as a director just does not know when to say no to Pacino the actor. After last year for me now the definitive Richard will be Ian McKellen. To see Pacino overpowering the role of Richard as he overpowers so many of his roles is almost painful. There are places that the plotting of the film is inconsistent. For example, apparently the actors are making no more than a film version of the play, but at one point Pacino argues with the adaptation's putative director as to whether they should have an expert discussing the play looking into the camera. Pacino's allusions to his other films amount almost to product placements--at one point he refers to a scene of the play as the "meeting of the Dons," he wears a cap that says "Scent of a Woman," and intentionally or not RICHARD III has rather obvious plot parallels to SCARFACE. The positives of LOOKING FOR RICHARD would dwarf the negatives if it were not for the latter taking too much precious time.
Pacino's feature-length discussion of Shakespeare also makes some telling points about the people who play Shakespeare. John Gielgud's viewpoint seems so plain and simple while Vanessa Redgrave goes off into a rambunctious and pretentious incoherence about the "pentameter of the soul." These discussions by some of the great actors of our time into why the Bard does what he does with language and how his plays are to be acted will undoubtedly be used in the years to come as part of college courses, yet it is entertaining enough for paying audiences even while it instructs. Even the street interviews are instructive and show a range of people from the well-dressed who have never seen a Shakespeare play to one man obviously less fortunate who waxes on about how if in school if we read more Shakespeare we would know how to feel and would have less violence in the streets. The film's playful approach to the classic starts at the very opening credits that at first say KING RICHARD, then fill in the additional letters to say LOOKING FOR RICHARD. It is Pacino's point of view that today's actors are the inheritors of a grand tradition of acting and drama, the centerpiece of which is the contribution of William Shakespeare.
If Pacino's goal were just to make this one play accessible, which in large part it was, I would say he fell short of last year's production which shows more of the play without ever being inaccessible. For the additional insights into the plays of Shakespeare and the acting required in them I would say LOOKING FOR RICHARD is more successful. I rate it a high +1 on the -4 to +4 scale.
Mark R. Leeper<EMAIL_ADDRESS>The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).
The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.
Please direct comments/criticisms of the review to relevant newsgroups.
Broken URLs inthe reviews are the responsibility of the author.
The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.
Related links: index of all rec.arts.movies.reviews reviews


channel.a8a8a8 __
channel.363636 __
channel.cecece __
channel.6e6e6e __
octree __
channel.020202 __
channel.fcfcfc __
channel.8b8b8b __
binary __
channel.515151 __


This transition indicates that a Vendor approved a request to cancel a subscription. Therefore, the system provides this terminating subscription with the Terminated status. Note that this status represent a terminal state. Thus, no further actions with this subscriptions are required or available.
A subscription with Terminating status and an approved subscription cancellation request.
A subscription with the Terminated status.


To provide a water resources tool that integrates engineering and consequence software to support a wide range of water resources applications, including watershed and systems based risk analysis.
Develop the primary integration tool for engineering and water resources studies


To install the library run $ yarn add device-performance-metrics
in the root of your project.
Importing the library globally:
import PerformanceMetrics from 'device-performance-metrics';
const performanceMetrics: PerformanceMetrics = new PerformanceMetrics();
const browser = performanceMetrics.deviceSpecifications.getBrowser();
const fps = performanceMetrics.fpscounter.fps;
const bandwidth = performanceMetrics.networkBandwidtInformation.getAverageBandwidth();
Or tree shake the library:
import { DeviceSpecifications } from 'device-performance-metrics';
import { NetworkBandwidthInformation } from 'device-performance-metrics';
import { FPSCounter } from 'device-performance-metrics';
const deviceSpecs = new DeviceSpecifications();
const browser = deviceSpecs.getBrowser();
const networkBandwidth = new NetworkBandwidthInformation();
const avgBandwidth = networkBandwidth.getAverageBandwidth();
const fpsCounter = new FPSCounter();
const fps = fpsCounter.fps;
The class DeviceSpecifications
gives you the ability to get basic specifications about your user's device. For example his browser and OS:
import { DeviceSpecifications } from 'device-performance-metrics';
const deviceSpecs: DeviceSpecifications = new DeviceSpecifications();
const browser = deviceSpecs.getBrowser();
const browserName = browser.name;
const browserVersion = browser.version;
const OS = deviceSpecs.getOS();
const OSName = OS.name;
const OSVersion = OS.version;
console.log(`Browser: ${browserName}(${browserVersion}), OS: ${OSName}(${OSVersion})`);
// example log: 'Browser: Chrome(73.0.3683), OS: MacOS(10.14.4)'
If you need to get information about the bandwidth you can use the NetworkBandwidthInformation
class.
import { NetworkBandwidthInformation } from 'device-performance-metrics';
const networkInfo: NetworkBandwidthInformation = new NetworkBandwidthInformation();
// Logs an array of all measured bandwidths found when the class is contstructed
console.log(networkInfo.bandwidths);
// example log: [1432, 4234, 7686]
// Logs an avaerge of all measured bandwidths found when the class is contstructed
console.log(`${networkInfo.averageBandwidth}bps`);
// example log: 3973bpms
// Because the above values are made when the class is contstructed you also directly trigger the functions that get the data, for example:
console.log(networkInfo.getAverageBandwidth());
// example log: 4264bpms
The FPSCounter
class gives you the ability to get the current framerate.
import { FPSCounter } from 'device-performance-metrics';
const fpsCounter: FPSCounter = new FPSCounter();
// Logs the current FPS
console.log(`${fpsCounter.fps}fps`)
// Example log: 60fps
If you want to get realtime information about the framerate you can use the setInterval()
function:
// Logs the current FPS every 500ms.
setInterval(() => {
console.log(`${fpsCounter.fps}fps`);
}, 500);
Detailed documentation can be found in the typedoc.
This project forces you to use yarn
;
$ yarn
$ yarn test
to test
$ yarn test:dev
to watch tests
$ yarn build
to build the code to the /lib
folder.
$ yarn doc
to generated documentation in the ./docs
folder
TODO
Generated using TypeDoc


Java most beginner
Latest post
how to add textarea into the jpanel or frame in java
In this tutorial we'll have a JTextArea on the jpanel.As well as i would
make a beatiful looking text area. i would apply some of the cool style to my
textArea.So i am suggesting to you all to have a look at this page
how to add button(JButton) to the jpanel or frame in java
In this tutorial we'll have a JButton on the jpanel.This will a lil bit simple button just to make you understand how to add button to the


{% extends "layout-2.html" %} {% block page_title %} GOV.UK payment page {% endblock %} {% block content %} Back Select how you want to pay Credit or Debit card Direct Debit (one-off payment) Continue Payment summary Fishing Licence UK Total amount: £12.00 {% endblock %}
Fishing Licence UK
£12.00


Daemon
Lifecycle
- service docker start
- service docker stop
Settings
- /etc/default/docker
- docker daemon settings file
Images
Provisionning
- docker pull image/name:label
- pull image image/name with label label from registry
- docker pull registryhost:registryport/image/name:label
- pull image image/name with label label from given registry
- docker push registryhost:registryport/image/name
- push image image/name to registryhost. image must have been tagged before
Control
- docker images
- list current available images
- docker tag image/name registryhost:registryport/image/name
- tag image/name to be pushed to new registry registryhost:registryport
Import/Export
- docker save -o image_archive.docker image/name
- save image to image_archive.docker file
- docker load image_archive.docker
- loads the images from the archive
Containers
Lifecycle
- docker ps -a
- list all containers
- docker rm name
- Remove container instance with given name or id
- docker run --name ubuntu_bash -it ubuntu bash
- runs bash sheel in an ubuntu instance nammed ubuntu_bash
Run options
- -d
- runs as a daemon
- -p HOSTPORT:CONTAINERPORT
- port routing between host port and container port
- -v host/path:/container/mount/point
- mount the host path to the container at the given mount point
Registry
Local
- docker run -d -p 5000:5000 --restart=always --name registry -v `pwd`/data:/var/lib/registry registry:2
- source
<<<<<<< HEAD
HOME
=======
HOME
>>>>>>> faa6aaf237eae4895460e74eebaa130feb27079a


Drive with Uber and earn great money as an independent contractor. Get paid weekly just for helping our community of riders get rides around town. Be your own boss and get paid in fares for driving on your own schedule.
Got a car? Turn it into a money machine. The city is buzzing and Uber makes it easy for you to cash in on the action. Plus, you've already got everything you need to get started.
Need something outside the 9 to 5? As an independent contractor with Uber, you’ve got freedom and flexibility to drive whenever you have time. Set your own schedule, so you can be there for all of life’s most important moments.
Whether you’re supporting your family or saving for something big, Uber gives you the freedom to get behind the wheel when it makes sense for you. Choose when you drive, where you go, and who you pick up.


This web app allows you to visualize data extracted from World Bank indicator statistics. Currently, indicators bearing on the development of total population (by country) and carbon dioxide emissions (by country) are included. Per capita carbon load in each enlisted country is also available.


There are several islands within this atoll. The principal island is Maamingili. The other islands to the west are mainly resort islands.
Position 03° 28'50"N, 72° 50'41"E (harbour entrance)
There is a deep water harbour at the eastern end Maamgili island. Capable of berthing boats up to 20m.
Due to the local boat building there are some repair facilities available as well as the usual provisioning and fuel from the busy town here.
Last updated April 2016.


Try Actions methods :
playOnce
playLoop
pauseNextEnd
pause
stop
resume
Artwork by ddraw
Click on the arrows
🡄
🡆


Much of what was discussed today seems to coincide with my previous thoughts on walking through the doors of Dev Bootcamp, come October. For one, I can identify with being worried about how I will stack up, whether or not I'll be able to grasp the various concepts of software development. I think that Shereef’s response to this idea is encouraging in that he seemed very confident that those who make it through the admissions process are capable. I like the emphasis on concentrating on developing or fostering a hunger to learn, rather than worrying about how much you currently know.
I also like the idea of concentrating on the more social aspects of software development. It seems that Dev Bootcamp hones in on the hidden art of teaching others to work cooperatively, and I am very much looking forward to putting that into practice. The idea of students sharing techniques and best practices, and in turn having them spread throughout the cohort sounds facinating. I look forward to discussing the importance of emotional empathy, and issues such as race and gender, because I feel that as a culture there is a real lack of understanding when it comes to these issues. I'm eager to engage as someone with a sociology and history academic background, in order to hopefully add something beneficial to the discussion.
I don’t know that my expectations have changed much, I think the video is in line with what I have come to expect from Dev Bootcamp. I am both excited and nervous at the idea of learning so much in such a short amount of time.
bendiciónes! mmc


|
{if $new_status == '1'}
[t]Your invitation for the following event has been accepted.[/t]
{/if}
{if $new_status == '2'}
[t]Your invitation for the following event has been decline.[/t]
{/if}
{if $new_status == '3'}
[t]Your invitation for the following event has received a change proposal.[/t]
{/if}
[t]Attendee[/t]: {$attendee_name}
[t]Event[/t]: {$event_name}
[t]Description[/t]: {$event_description}
[t]Location[/t]: {$event_location}
[t]Beginning[/t]: {$event_begin}
[t]End[/t]: {$event_end}
[t]Note[/t]: {$note}
|


The rendered form below show the output of combining the Dynamic Form + Form Builder. I will leave it to you to be more creative with the use case.


Barcelona utilizes JSF templating APIs and provides a main template.xhtml along with additional topbar, menu, footer fragments for the base layout. These xhtml files must be placed under WEB-INF folder and client pages should reference the template.xhtml as their template. Provided empty.xhtml is a sample content page using the main template.xhtml that defines "content" as the main ui:define placeholder. By default template defines 3 placeholders (page title, header content and actual content)to insert content and you can add more as per your requirements.
Sample page below uses the main template from Barcelona.
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui" template="/WEB-INF/template.xhtml"> <ui:define name="title">Test Page</ui:define> <ui:define name="content"> Content goes here </ui:define> </ui:composition>
Other required resources are the css, js and images that are located inside resources/barcelona-layout folder, simply copy the barcelona-layout folder to your %WEB-APP-FOLDER%/resources folder so that final path would be %WEB-APP-FOLDER%/resources/barcelona-layout/. Please refer to demo app or maven project of the demo app as the reference.
Barcelona provides 10 PrimeFaces themes out of the box, setup of a theme simple as including the theme jar in your classpath and defining primefaces.THEME context parameter in web.xml such as "primefaces-Barcelona-green". Full list of available themes are;
A custom theme can be developed by the following steps.
Here are the variables required to create a theme, you may need to change the last line according to the relative path of the sass folder in your application.
$primaryColor: #1976d2; $primaryDarkColor: #0D47A1; $primaryLightColor: #2196F3; $primaryTextColor: #FFFFFF; $accentColor: #FFC107; $accentDarkColor: #FFA000; $accentLightColor: #FFECB3; $accentTextColor: #000000; @import '../sass/theme/_theme';
An example sass command to compile the css would be;
sass src/main/webapp/resources/primefaces-barcelona-myown/theme.scss src/main/webapp/resources/primefaces-barcelona-myown/theme.css --sourcemap=none
Watch mode is handy to avoid compiling everytime when a change is made, instead use the following command so that sass generates the file whenever you make a customization. This builds all css files whenever a change is made to any scss file.
sass -w src/main/webapp/resources/ --sourcemap=none
Same can also be applied to layout itself;
Here are the variables required to create a layout, you may need to change the last line according to the relative path of the sass folder in your application.
$primaryColor:#607D8B; $primaryLightColor:#90A4AE; $primaryTextColor:#CFD8DC; $primaryTextHoverColor:#B0BEC5; $accentColor:#8BC34A; $accentLightColor:#DCEDC8; $accentTextColor:#ffffff; $activeMenuItemTextColor:#8BC34A; $darkActiveMenuItemTextColor:#8BC34A; $darkMenuItemTextColor:#dee0e3; $darkMenuItemInactiveTextColor:#757575; $darkMenuItemHoverBgColor:#545454; $darkSidemenuBgColor:#343434; $darkMenuBgColor:#424242; @import '../../sass/layout/_layout';
For both cases, several .scss files such as _layout.scss, _theme.scss or _variables.scss has to be present relative to your scss files, these are available inside the sass folder in the distribution.
In case you'd like to customize the structure not just the colors, the _variables.scss is where the structural variables (e.g. font size, paddings) for the layout are defined.
/* Common */ $fontSize:14px; $fontFamily:"Roboto","Helvetica Neue",sans-serif; $lineHeight:18px; $textColor:#424242; $textSecondaryColor:#757575; $borderRadius:3px; $dividerColor:#eaeaea; $dividerLightColor:#f8f8f8; $iconWidth:20px; $iconHeight:20px; $iconFontSize:20px; $grayBgColor:#757575; $hoverBgColor:#e8e8e8; $hoverTextColor:#000000; /* Layout */ $bodyBgColor:#fcfbfb; $menuItemHoverBgColor:#e8e8e8; $darkSidemenuBgColor:#343434; $darkMenuBgColor:#424242; $darkMenuItemTextColor:#dee0e3; $darkMenuItemHoverBgColor:#545454; $menuitemColor:#757575; $footerBgColor:#ffffff; /* Topbar */ $topbarSubmenuBgColor:#f7f7f7; $topbarSubmenuItemHoverBgColor:#e3e3e3; /******************************/ /* THEME */ /******************************/ $headerPadding:8px 14px; $headerTextColor:#ffffff; $contentPadding:8px 14px; $contentBorderColor:#d8d8d8; $contentBgColor:#ffffff; $inputBorderColor:#bdbdbd; $inputInvalidBorderColor:#e62a10; $inputBgColor:#ffffff; $inputErrorTextColor:#e62a10; $inputHeaderPadding:6px 10px; $buttonTextColor:#ffffff; $listItemPadding:6px 10px; $radioButtonBorderColor:#757575; $checkboxBorderColor:#757575; $errorMessageFontSize:11px; $errorMessageIconFontSize:13px; $dataTableRowBgColorEven:#f4f4f4; $paginatorPadding:6px 10px; $menuitemPadding:6px 10px;
Menu is a regular JSF component that supports PrimeFaces MenuModel API allowing both declarative and programmatic approaches. State is saved via a cookie and to remove it define a widgetVar to the menu and call PF('yourwidgetvar').clearMenuState(). To use the menu add the primefaces-barcelona-{version}.jar to your classpath and import the http://primefaces.org/barcelona namespace.
xmlns:pa="http://primefaces.org/barcelona"> <pa:tabMenu> <pa:tab icon="fa fa-cube" title="Features"> <h:form id="menu-form"> <pa:menu widgetVar="menu"> </pa:menu> </h:Form> </pa:tab> <pa:tab icon="fa fa-inbox" title="Inbox"> </pa:tab> <pa:tab icon="fa fa-calendar-o" title="Calendar"> </pa:tab> </pa:tabMenu>
Menu has 2 modes, inline and overlay. Layout wrapper element in template.xhtml is used to define which mode to use by adding specific classes. List below indicates the style classes for each mode.
For example to create an overlay menu, the div element should be in following form;

 ...

RTL orintetation for the layout is enabled by adding "layout-rtl" to the main layout-wrapper element.

 ...

Barcelona provides various helper features such as material iconset compatible with PrimeFaces components and helper classes. Visit
Various elements display a ripple element on mousedown event, if you prefer to remove this effect, simply remove the ripple.js and ripple.css files from template.xhtml.
Barcelona Layout uses font awesome icons for layout so enable font awesome support in PrimeFaces by setting primefaces.FONT_AWESOME context parameter in web.xml as true. If your PrimeFaces version does not have the font awesome integration, include the font-awesome manually in your application.
Barcelona uses new PrimeFaces Grid CSS (ui-g-*) throughout the samples, we strongly suggest using Grid CSS as your layout framework as it is well tested and supported by PrimeFaces. Grid CSS is automatically included on newer versions however if your PrimeFaces version is older than 5.3.14, add the provided grid.css file under /barcelona-layout/css/ folder to your template manually.


--- title: Linear Spatial Filters with GNU Octave layout: post tags: [octave, tutorial] uuid: e3b9e7a9-5669-3173-f84d-d8af0d8f8be4 ---
I have gotten several e-mails lately about using GNU Octave. One specifically was about blurring images in Octave. In response, I am writing this in-depth post to cover spatial filters, and how to use them in GNU Octave (a free implementation of the Matlab programming language). This should be the sort of information you would find near the beginning of an introductory digital image processing textbook, but written out more simply. In the future, I will probably be writing a post covering non-linear spatial and/or frequency domain filters in Octave.
If you want to follow along in Octave, I strongly recommend that you
upgrade to the new Octave 3.0. It is considered stable, but differs
significantly from Octave 2.1, which many people may be used to. You
will also need to install
the image
processing package
from Octave-Forge. To get
help with any Octave function, just type help
<function>
.
The most common linear spatial image filtering involves convolving a filter mask, sometimes called a convolution kernel, over an image, which is a two-dimensional matrix. In the case of an RGB color image, the image is actually composed of three two-dimensional grayscale images, each representing a single color, where each is convolved with the filter mask separately.
Convolution is sliding a mask over an image. The new value at the mask's position is the sum of the value of each element of the mask multiplied by the value of the image at that position. For an example, let's start with 1-dimensional convolution. Define a mask,
5 3 2 4 8
The 2 is the anchor for the mask. Define an image,
0 0 1 2 1 0 0
As we convolve, the mask will extend beyond the image at the edges. One way to handle this is to pad the image with 0's. We start by placing the mask at the left edge. (zero-padding is underlined)
Mask: 5 3 2 4 8 Image: 0 0 0 0 1 2 1 0 0
The first output value is 8, as every other element of the mask is multiplied by zero.
Output: 8 x x x x x x
Now, slide the mask over by one position,
Mask: 5 3 2 4 8 Image: 0 0 0 1 2 1 0 0
The output here is 20, because 8*2 + 4*1 = 20;
Output: 8 20 x x x x x
If we continue sliding the mask along, the output becomes,
Output: 8 20 18 11 13 13 5
Here is the correlation done in Octave interactively,
(filter2()
is the correlation function).
octave> filter2([5 3 2 4 8], [0 0 1 2 1 0 0]) ans = 8 20 18 11 13 13 5
The same thing happens in two-dimensional convolution, with the mask moving in the vertical direction as well, so that each element in the image is covered.
Sometimes you will hear this described as correlation
(Octave's filter2
) or convolution
(Octave's conv2
). The only difference between these
operations is that in convolution the filter masked is rotated 180
degrees. Whoop-dee-doo. Most of the time your filter is probably
symmetrical anyway. So, don't worry much about the difference between
these two. Especially in Octave, where rotating a matrix is easy
(see rot90()
).
Now that we know convolution, let's introduce the sample image we will be using. I carefully put this together in Inkscape, which should give us a nice scalable test image. When converting to a raster format, there is a bit of unwanted anti-aliasing going on (couldn't find a way to turn that off), but it is minimal.
Save that image (the PNG file, not the linked SVG file) where you can
get to it in Octave. Now, let's load the image into Octave
using imread()
.
m = imread("image-test.png");
The image is a grayscale image, so it has only one layer. The size
of m
should be 300x300. You can check this like so (note
the lack of semicolon so we can see the output),
size(m)
You can view the image stored in m
with imshow
. It doesn't care about the image dimensions
or size, so until you resize the plot window, it will probably be
stretched.
imshow(m);
Now, let's make an extremely simple 5x5 filter mask.
f = ones(5) * 1/25
Octave will show us what this matrix looks like.
f = 0.040000 0.040000 0.040000 0.040000 0.040000 0.040000 0.040000 0.040000 0.040000 0.040000 0.040000 0.040000 0.040000 0.040000 0.040000 0.040000 0.040000 0.040000 0.040000 0.040000 0.040000 0.040000 0.040000 0.040000 0.040000
This filter mask is called an averaging filter. It simply averages all the pixels around the image (think about how this works out in the convolution). The effect will be to blur the image. It is important to note here that the sum of the elements is 1 (or 100% if you are thinking of averages). You can check it like so,
sum(f(:))
Now, to convolve the image with the filter mask
using filter2()
.
ave_m = filter2(f, m);
You can view the filtered image again with imshow()
except that we need to first convert the image matrix to a matrix of
8-bit unsigned integers. It is kind of annoying that we need this, but
this is the way it is as of this writing.
ave_m = uint8(ave_m); imshow(ave_m);
Or, we can save this image to a file
using imwrite()
. Just like with imshow()
,
you will first need to convert the image to uint8
.
imwrite("averaged.png", ave_m);
There are a few things to notice about this image. First there is a
black border around the outside of the filtered image. This is due to
the zero-padding (black border) done by filter2()
. The
border of the image had 0's averaged into them. Second, some parts of
the blurred image are "noisy". Here are some selected parts at 4x zoom.
Notice how the circle, and the "a" seem a little bit boxy? This is due to the shape of our filter. Also notice that the blurring isn't as smooth as it could be. This is because the filter itself isn't very smooth. We'll fix both these problems with a new filter later.
First, here is how we can fix the border problem: we pad the image with itself. Octave provides us three easy ways to do this. The first is replicate padding: the padding outside the image is the same as the nearest border pixel in the image. Circular padding: the padding from from the opposite side of the image, as if it was wrapped. This would be a good choice for a periodic image. Last, and probably the most useful is symmetric: the padding is a mirror reflection of the image itself.
To apply symmetric padding, we use the padarray()
function. We only want to pad the image by the amount that the mask
will "hang off". Let's pad the original image for a 9x9 filter, which
will hang off by 4 pixels each way,
mpad = padarray(m, [4 4], "symmetric");
Next, we will replace the averaging filter with a 2D Gaussian
distribution. The Gaussian, or normal, distribution has many wonderful
and useful properties (as a statistics professor I had once said,
anyone who considers themselves to be educated should know about the
normal distribution). One property that makes it useful is that if we
integrate the Gaussian distribution from minus infinity to infinity,
the result is 1. The easiest way to get the curve without having to
type in the equation is using fspecial()
: a special
function for creating image filters.
f_gauss = fspecial("gaussian", 9, 2);
This creates a 9x9 Gaussian filter with variance 2. The variance controls the effective size of the filter. Increasing the size of the filter from 9 to 99 will actually have virtually no impact on the final result. It just needs to be large enough to cover the curve. Six times the variance covers over 99% of the curve, so for a variance of 2, a filter of size 7x7 (always make your filters odd in size) is plenty. A larger filter means a longer convolution time. Here is what the 9x9 filter looks like,
And to filter with the Gaussian,
gauss_m = filter2(f_gauss, mpad, "valid"; gauss_m = uint8(guass_m);
Notice the extra argument "valid"
? Since we padded the
image before filtering, we don't want this padding to be part of the
image result. filter2()
normally returns an image of the
same size as the input image, but we only want the part that didn't
undergo (additional) zero-padding. The result is now the same size as
the original image, but without the messy border,
Also, compare the result to the average filter above. See how much smoother this image is? If you are interested in blurring an image, you will generally want to go with a Gaussian filter like this.
Now I will let you in on a little shortcut. In Matlab, there is a
function called imfilter
which does the padding and
filtering in one step. As of this writing, the Octave-Forge image
package doesn't officially include this function, but it is there in
the source repository now, meaning that it will probably appear in the
next version of that package. I actually wrote my own before I found
this one. You can grab the official one
here:
imfilter.m
With this new function, we can filter with the Gaussian and save like
this. Notice the flipping of the first two arguments
from filter2
, as well as the lack of converting
to uint8
.
gauss_m = imfilter(m, f, "symmetric"); imwrite("gauss.png", gauss_m);
imfilter()
will also handle the 3-layer color images
seamlessly. Without it, you would need to run filter2()
on each layer separately.
So that is just about all there is. fspecial()
has many
more filters available including motion
blur,
unsharp, and edge detection. For example,
the Sobel edge
detector,
octave:25> fspecial("sobel") ans = 1 2 1 0 0 0 -1 -2 -1
It is good at detecting edges in one direction. We can rotate this each way to detect edges all over the image.
mf = uint8(zeros(size(m))); for i = 0:3 mf += imfilter(m, rot90(fspecial("sobel"), i)); end imshow(mf)
Happy Hacking with Octave!


As you are going, with our Lord God Jesus Christ aiding, to manage the church in the Gaulish lands, we ask that your dear self, from the gold coins that you will receive, purchase clothing for the poor or seventeen or eighteen year old English boys, who should do well in monasteries after being given to God, since Gaulish gold coins, which cannot be spent in our own land, might be usefully spent in their own region.
Indeed, if you can recover any of the money that is said to have been stolen, from this also we would like you to secure clothing for the poor, or, as we have already said, boys who might do well in the service of the almighty God.
But because those who are found in that place are pagans, I hope that a priest will be sent with them, so that if some disease touches them on the road, he'd be responsible for baptizing those who were about to die.
Therefore may your dear self make haste to diligently complete these matters.


Weak Lensing Shear¶
The Shear class¶
-
class
galsim.
Shear
(*args, **kwargs)[source]¶ A class to represent shears in a variety of ways.
The python Shear class (galsim.Shear) can be initialized in a variety of ways to represent shape distortions. A shear is an operation that transforms a circle into an ellipse with minor-to-major axis ratio b/a, with position angle beta, while conserving the area (see below for a discussion of the implications of this choice). Given the multiple definitions of ellipticity, we have multiple definitions of shear:
reduced shear :math:`|g| = (a - b)/(a + b)` distortion :math:`|e| = (a^2 - b^2)/(a^2 + b^2)` conformal shear :math:`\eta = log(b/a)` minor-to-major axis ratio :math:`q = b/a`
These can be thought of as a magnitude and a real-space position angle beta, or as two components, e.g., g1 and g2, with:
\[g1 = |g| cos(2*beta) g2 = |g| sin(2*beta)\]Note: beta is _not_ the phase of a complex valued shear. Rather, the complex shear is g1 + i g2 = g exp(2 i beta). Likewise for eta or e. The phase of the complex value is 2 beta.
The following are all examples of valid calls to initialize a Shear object:
>>> s = galsim.Shear() # empty constructor sets ellipticity/shear to zero >>> s = galsim.Shear(g1=0.05, g2=0.05) >>> s = galsim.Shear(g1=0.05) # assumes g2=0 >>> s = galsim.Shear(e1=0.05, e2=0.05) >>> s = galsim.Shear(e2=0.05) # assumes e1=0 >>> s = galsim.Shear(eta1=0.07, eta2=-0.1) >>> s = galsim.Shear(eta=0.05, beta=45.0*galsim.degrees) >>> s = galsim.Shear(g=0.05, beta=0.25*numpy.pi*galsim.radians) >>> s = galsim.Shear(e=0.3, beta=30.0*galsim.degrees) >>> s = galsim.Shear(q=0.5, beta=0.0*galsim.radians)
There can be no mixing and matching, e.g., specifying
g1
ande2
. It is permissible to only specify one of two components, with the other assumed to be zero. If a magnitude such ase
,g
,eta
, orq
is specified, thenbeta
is also required to be specified. It is possible to initialize a Shear with zero reduced shear by specifying no args or kwargs, i.e.galsim.Shear()
.In addition, for use cases where extreme efficiency is required, you can skip all the normal sanity checks and branches in the regular Shear constructor by using a leading underscore with the complex shear (g1 + 1j * g2):
>>> s = galsim._Shear(0.05 + 0.03j) # Equivalent to galsim.Shear(g1=0.05, g2=0.03)
Since we have defined a Shear as a transformation that preserves area, this means that it is not a precise description of what happens during the process of weak lensing. The coordinate transformation that occurs during the actual weak lensing process is such that if a galaxy is sheared by some
(gamma_1, gamma_2)
, and then sheared by(-gamma_1, -gamma_2)
, it will in the end return to its original shape, but will have changed in area due to the magnification,mu = 1/((1.-kappa)**2 - (gamma_1**2 + gamma_2**2))
, which is not equal to one for non-zero shear even for convergencekappa=0
. Application of a Shear using theGSObject.shear
method does not include this area change. To properly incorporate the effective change in area due to shear, it is necessary to either (a) define the Shear object, use theGSObject.shear
method, and separately use theGSObject.magnify
method, or (b) use theGSObject.lens
method that simultaneously magnifies and shears.-
getMatrix
()[source]¶ Return the matrix that tells how this shear acts on a position vector:
If a field is sheared by some shear, s, then the position (x,y) -> (x’,y’) according to:
[ x’ ] = S [ x ] [ y’ ] [ y ]
where S = s.getMatrix().
- Specifically, the matrix is S = (1-g^2)^(-1/2) [ 1+g1 , g2 ]
[ g2 , 1-g1 ]
-
rotationWith
(other)[source]¶ Return the rotation angle associated with the addition of two shears.
The effect of two shears is not just a single net shear. There is also a rotation associated with it. This is easiest to understand in terms of the matrix representations:
If s3 = s1 + s2, and the corresponding shear matrices are S1,S2,S3, then S3 R = S1 S2, where R is a rotation matrix:
- R = [ cos(theta) , -sin(theta) ]
[ sin(theta) , cos(theta) ]
and theta is the return value (as a galsim.Angle) from s1.rotationWith(s2).
-
Power Spectrum Shears¶
-
class
galsim.
PowerSpectrum
(e_power_function=None, b_power_function=None, delta2=False, units=coord.arcsec)[source]¶ Class to represent a lensing shear field according to some power spectrum P(k).
General considerations:
A PowerSpectrum represents some (flat-sky) shear power spectrum, either for gridded points or at arbitary positions. This class is originally initialized with a power spectrum from which we would like to generate g1 and g2 (and, optionally, convergence kappa) values. It generates shears on a grid, and if necessary, when getShear() (or another
get
method) is called, it will interpolate to the requested positions. For detail on how these processes are carried out, please see the document in the GalSim repository,devel/modules/lensing_engine.pdf
.This class generates the shears according to the input power spectrum using a DFT approach, which means that we implicitly assume our discrete representation of P(k) on a grid is one complete cell in an infinite periodic series. We are making assumptions about what P(k) is doing outside of our minimum and maximum k range, and those must be kept in mind when comparing with theoretical expectations. Specifically, since the power spectrum is realized on only a finite grid it has been been effectively bandpass filtered between a minimum and maximum k value in each of the k1, k2 directions. See the
buildGrid
method for more information.As a result, the shear generation currently does not include sample variance due to coverage of a finite patch. We explicitly enforce
P(k=0)=0
, which is true for the full sky in a reasonable cosmological model, but it ignores the fact that our little patch of sky might reasonably live in some special region with respect to shear correlations. OurP(k=0)=0
is essentially setting the integrated power below our minimum k value to zero. The implications of the discrete representation, and theP(k=0)=0
choice, are discussed in more detail indevel/modules/lensing_engine.pdf
.The effective shear correlation function for the gridded points will be modified both because of the DFT approach to representing shears according to a power spectrum, and because of the power cutoff below and above the minimum k values. The latter effect can be particularly important on large scales, so the
buildGrid
method has some keywords that can be used to reduce the impact of the minimum k set by the grid extent. The calculateXi() method can be used to calculate the expected shear correlation functions given the minimum and maximum k for some grid (but ignoring the discrete vs. continuous Fourier transform effects), for comparison with some ideal theoretical correlation function given an infinite k range.When interpolating the shears to non-gridded points, the shear correlation function and power spectrum are modified; see the getShear() and other
get
method docstrings for more details.The power spectra to be used:
When creating a PowerSpectrum instance, you must specify at least one of the E or B mode power spectra, which is normally given as a function P(k). The typical thing is to just use a lambda function in Python (i.e., a function that is not associated with a name); for example, to define P(k)=k^2, one would use
lambda k : k**2
. But the power spectra can also be more complicated user-defined functions that take a single argumentk
and return the power at thatk
value, or they can be instances of the LookupTable class for power spectra that are known at particulark
values but for which there is not a simple analytic form.Cosmologists often express the power spectra in terms of an expansion in spherical harmonics (ell), i.e., the C_ell values. In the flat-sky limit, we can replace ell with k and C_ell with P(k). Thus, k and P(k) have dimensions of inverse angle and angle^2, respectively. It is quite common for people to plot ell(ell+1)C_ell/2pi, a dimensionless quantity; the analogous flat-sky quantity is Delta^2 = k^2 P(k)/2pi. By default, the PowerSpectrum object assumes it is getting P(k), but it is possible to instead give it Delta^2 by setting the optional keyword
delta2 = True
in the constructor.The power functions must return a list/array that is the same size as what they are given, e.g., in the case of no power or constant power, a function that just returns a float would not be permitted; it would have to return an array of floats all with the same value.
It is important to note that the power spectra used to initialize the PowerSpectrum object should use the same units for k and P(k), i.e., if k is in inverse radians then P(k) should be in radians^2 (as is natural for outputs from a cosmological shear power spectrum calculator). However, when we actually draw images, there is a natural scale that defines the pitch of the image, which is typically taken to be arcsec. This definition of a specific length scale means that by default we assume all quantities to the PowerSpectrum are in arcsec, and those are the units used for internal calculations, but the
units
keyword can be used to specify different input units for P(k) (again, within the constraint that k and P(k) must be consistent). If thedelta2
keyword is set to specify that the input is actually the dimensionless power Delta^2, then the inputunits
are taken to apply only to the k values.- Parameters
e_power_function – A function or other callable that accepts a NumPy array of abs(k) values, and returns the E-mode power spectrum P_E(abs(k)) in an array of the same shape. The function should return the power spectrum desired in the E (gradient) mode of the image. It may also be a string that can be converted to a function using
eval('lambda k : '+e_power_function)
, a LookupTable, orfile_name
from which to read in a LookupTable. If afile_name
is given, the resulting LookupTable uses the defaults for the LookupTable class, namely spline interpolation in P(k). Users who wish to deviate from those defaults (for example, to interpolate in log(P) and log(k), as might be more natural for power-law functions) should instead read in the file to create a LookupTable using the necessary non-default settings. [default: None, which means no E-mode power.]b_power_function – A function or other callable that accepts a NumPy array of abs(k) values, and returns the B-mode power spectrum P_B(abs(k)) in an array of the same shape. The function should return the power spectrum desired in the B (curl) mode of the image. See description of
e_power_function
for input format options. [default: None, which means no B-mode power.]delta2 – Is the power actually given as dimensionless Delta^2, which requires us to multiply by 2pi / k^2 to get the shear power P(k) in units of angle^2? [default: False]
units – The angular units used for the power spectrum (i.e. the units of k^-1 and sqrt(P)). This should be either an AngleUnit instance (e.g. galsim.radians) or a string (e.g. ‘radians’). [default: arcsec]
-
buildGrid
(grid_spacing, ngrid, rng=None, interpolant=None, center=galsim.PositionD(x=0.0, y=0.0), units=coord.arcsec, get_convergence=False, kmax_factor=1, kmin_factor=1, bandlimit='hard', variance=None)[source]¶ Generate a realization of the current power spectrum on the specified grid.
Basic functionality:
This function will generate a Gaussian random realization of the specified E and B mode shear power spectra at a grid of positions, specified by the input parameters
grid_spacing
(distance between grid points) andngrid
(number of grid points in each direction.) Units forgrid_spacing
andcenter
can be specified using theunits
keyword; the default is arcsec, which is how all values are stored internally. It automatically computes and stores grids for the shears and convergence. However, since many users are primarily concerned with shape distortion due to shear, the default is to return only the shear components; theget_convergence
keyword can be used to also return the convergence.The quantities that are returned are the theoretical shears and convergences, usually denoted gamma and kappa, respectively. Users who wish to obtain the more observationally-relevant reduced shear and magnification (that describe real lensing distortions) can either use the getShear(), getMagnification(), or getLensing() methods after
buildGrid
, or can use the convenience function galsim.lensing_ps.theoryToObserved() to convert from theoretical to observed quantities.Effects of DFT approach, and keywords that can be used to ameliorate them:
Note that the shears generated using this method correspond to the PowerSpectrum multiplied by a sharp bandpass filter, set by the dimensions of the grid.
The filter sets P(k) = 0 for:
abs(k1), abs(k2) < kmin / 2
and:
abs(k1), abs(k2) > kmax + kmin / 2
where:
kmin = 2. * pi / (ngrid * grid_spacing) kmax = pi / grid_spacing
and where we have adopted the convention that grid points at a given
k
represent the interval between (k - dk/2) and (k + dk/2) (noting that the grid spacing dk in k space is equivalent tokmin
).It is worth remembering that this bandpass filter will not look like a circular annulus in 2D
k
space, but is rather more like a thick-sided picture frame, having a small square central cutout of dimensionskmin
bykmin
. These properties are visible in the shears generated by this method.If you care about these effects and want to ameliorate their effect, there are two optional kwargs you can provide:
kmin_factor
andkmax_factor
, both of which are 1 by default. These should be integers >= 1 that specify some factor smaller or larger (for kmin and kmax respectively) you want the code to use for the underlying grid in fourier space. The final shear grid is returned using the specifiedngrid
andgrid_spacing
parameters. But the intermediate grid in Fourier space will be larger by the specified factors.Note: These are really just for convenience, since you could easily get the same effect by providing different values of ngrid and grid_spacing and then take a subset of them. The
kmin_factor
andkmax_factor
just handle the scalings appropriately for you.Use of
kmin_factor
andkmax_factor
should depend on the desired application. For accurate representation of power spectra, one should not change these values from their defaults of 1. Changing them from one means the E- and B-mode power spectra that are input will be valid for the larger intermediate grids that get generated in Fourier space, but not necessarily for the smaller ones that get returned to the user. However, for accurate representation of cosmological shear correlation functions, use ofkmin_factor
larger than one can be helpful in getting the shear correlations closer to the ideal theoretical ones (seedevel/module/lensing_engine.pdf
for details).Aliasing:
If the user provides a power spectrum that does not include a cutoff at kmax, then our method of generating shears will result in aliasing that will show up in both E- and B-modes. Thus the
buildGrid
method accepts an optional keyword argument calledbandlimit
that can tell the PowerSpectrum object to cut off power above kmax automatically, where the relevant kmax is larger than the grid Nyquist frequency by a factor ofkmax_factor
. The allowed values forbandlimit
are None (i.e., do nothing),hard
(set power to zero above the band limit), orsoft
(use an arctan-based softening function to make the power go gradually to zero above the band limit). By default,bandlimit=hard
. Use of this keyword does nothing to the internal representation of the power spectrum, so if the user calls thebuildGrid
method again, they will need to setbandlimit
again (and if their grid setup is different in a way that changeskmax
, then that’s fine).Interpolation:
If the grid is being created for the purpose of later interpolating to random positions, the following findings should be kept in mind: since the interpolant modifies the effective shear correlation function on scales comparable to <~3x the grid spacing, the grid spacing should be chosen to be at least 3 times smaller than the minimum scales on which the user wishes to reproduce the shear correlation function accurately. Ideally, the grid should be somewhat larger than the region in which shears at random points are needed, so that edge effects in the interpolation will not be important. For this purpose, there should be >~5 grid points outside of the region in which interpolation will take place. Ignoring this edge effect and using the grid for interpolation out to its edges can suppress shear correlations on all scales by an amount that depends on the grid size; for a 100x100 grid, the suppression is ~2-3%. Note that the above numbers came from tests that use a cosmological shear power spectrum; precise figures for this suppression can also depend on the shear correlation function itself.
Sign conventions and other info:
Note also that the convention for axis orientation differs from that for the GREAT10 challenge, so when using codes that deal with GREAT10 challenge outputs, the sign of our g2 shear component must be flipped.
For more information on the effects of finite grid representation of the power spectrum see
devel/modules/lensing_engine.pdf
.Some examples:
Get shears on a grid of points separated by 1 arcsec:
>>> my_ps = galsim.PowerSpectrum(lambda k : k**2) >>> g1, g2 = my_ps.buildGrid(grid_spacing = 1., ngrid = 100)
The returned g1, g2 are 2-d NumPy arrays of values, corresponding to the values of g1 and g2 at the locations of the grid points.
For a given value of
grid_spacing
andngrid
, we could get the x and y values on the grid using:>>> import numpy as np >>> min = (-ngrid/2 + 0.5) * grid_spacing >>> max = (ngrid/2 - 0.5) * grid_spacing >>> x, y = np.meshgrid(np.arange(min,max+grid_spacing,grid_spacing), ... np.arange(min,max+grid_spacing,grid_spacing))
where the center of the grid is taken to be (0,0).
Rebuild the grid using a particular rng and set the location of the center of the grid to be something other than the default (0,0):
>>> g1, g2 = my_ps.buildGrid(grid_spacing = 8., ngrid = 65, ... rng = galsim.BaseDeviate(1413231), ... center = galsim.PositionD(256.5, 256.5) )
Make a PowerSpectrum from a tabulated P(k) that gets interpolated to find the power at all necessary values of k, then generate shears and convergences on a grid, and convert to reduced shear and magnification so they can be used to transform galaxy images. E.g., assuming that k and P_k are NumPy arrays containing k and P(k):
>>> tab_pk = galsim.LookupTable(k, P_k) >>> my_ps = galsim.PowerSpectrum(tab_pk) >>> g1, g2, kappa = my_ps.buildGrid(grid_spacing = 1., ngrid = 100, ... get_convergence = True) >>> g1_r, g2_r, mu = galsim.lensing_ps.theoryToObserved(g1, g2, kappa)
- Parameters
grid_spacing – Spacing for an evenly spaced grid of points, by default in arcsec for consistency with the natural length scale of images created using the drawImage() method. Other units can be specified using the
units
keyword.ngrid – Number of grid points in each dimension. [Must be an integer]
rng – A BaseDeviate object for drawing the random numbers. [default: None]
interpolant – Interpolant that will be used for interpolating the gridded shears by methods like getShear(), getConvergence(), etc. if they are later called. [default: galsim.Lanczos(5)]
center – If setting up a new grid, define what position you want to consider the center of that grid. Units must be consistent with those for
grid_spacing
. [default: galsim.PositionD(0,0)]units – The angular units used for the positions. [default: arcsec]
get_convergence – Return the convergence in addition to the shear? Regardless of the value of
get_convergence
, the convergence will still be computed and stored for future use. [default: False]kmin_factor –
Factor by which the grid spacing in fourier space is smaller than the default. i.e.:
kmin = 2. * pi / (ngrid * grid_spacing) / kmin_factor
[default: 1; must be an integer]
kmax_factor –
Factor by which the overall grid in fourier space is larger than the default. i.e.:
kmax = pi / grid_spacing * kmax_factor
[default: 1; must be an integer]
bandlimit – Keyword determining how to handle power P(k) above the limiting k value, kmax. The options None, ‘hard’, and ‘soft’ correspond to doing nothing (i.e., allow P(>kmax) to be aliased to lower k values), cutting off all power above kmax, and applying a softening filter to gradually cut off power above kmax. Use of this keyword does not modify the internally-stored power spectrum, just the shears generated for this particular call to
buildGrid
. [default: “hard”]variance – Optionally renormalize the variance of the output shears to a given value. This is useful if you know the functional form of the power spectrum you want, but not the normalization. This lets you set the normalization separately. The resulting shears should have var(g1) + var(g2) ~= variance. If only e_power_function is given, then this is also the variance of kappa. Otherwise, the variance of kappa may be smaller than the specified variance. [default: None]
- Returns
the tuple (g1,g2[,kappa]), where each is a 2-d NumPy array and kappa is included iff
get_convergence
is set to True.
-
calculateXi
(grid_spacing, ngrid, kmax_factor=1, kmin_factor=1, n_theta=100, units=coord.arcsec, bandlimit='hard')[source]¶ Calculate shear correlation functions for the current power spectrum on the specified grid.
This function will calculate the theoretical shear correlation functions, \(\xi_+\) and \(\xi_-\), for this power spectrum and the grid configuration specified using keyword arguments, taking into account the minimum and maximum k range implied by the grid parameters,
kmin_factor
andkmax_factor
. Most theoretical correlation function calculators assume an infinite k range, so this utility can be used to check how close the chosen grid parameters (and the implied minimum and maximum k) come to the “ideal” result. This is particularly useful on large scales, since in practice the finite grid extent limits the minimum k value and therefore can suppress shear correlations on large scales. Note that the actual shear correlation function in the generated shears will still differ from the one calculated here due to differences between the discrete and continuous Fourier transform.The quantities that are returned are three NumPy arrays: separation theta (in the adopted units), \(\xi_+\), and \(\xi_-\). These are defined in terms of the E- and B-mode shear power spectrum as in the document
devel/modules/lensing_engine.pdf
, equations 2 and 3. The values that are returned are for a particular theta value, not an average over a range of theta values in some bin of finite width.This method has been tested with cosmological shear power spectra; users should check for sanity of outputs if attempting to use power spectra that have very different scalings with k.
- Parameters
grid_spacing – Spacing for an evenly spaced grid of points, by default in arcsec for consistency with the natural length scale of images created using the drawImage() method. Other units can be specified using the
units
keyword.ngrid – Number of grid points in each dimension. [Must be an integer]
units – The angular units used for the positions. [default = arcsec]
kmin_factor –
(Optional) Factor by which the grid spacing in fourier space is smaller than the default. i.e.:
kmin = 2. * pi / (ngrid * grid_spacing) / kmin_factor
[default
kmin_factor = 1
; must be an integer]kmax_factor –
(Optional) Factor by which the overall grid in fourier space is larger than the default. i.e.:
kmax = pi / grid_spacing * kmax_factor
[default
kmax_factor = 1
; must be an integer]n_theta – (Optional) Number of logarithmically spaced bins in angular separation. [default
n_theta=100
]bandlimit – (Optional) Keyword determining how to handle power P(k) above the limiting k value, kmax. The options None, ‘hard’, and ‘soft’ correspond to doing nothing (i.e., allow P(>kmax) to be aliased to lower k values), cutting off all power above kmax, and applying a softening filter to gradually cut off power above kmax. Use of this keyword does not modify the internally-stored power spectrum, just the result generated by this particular call to
calculateXi
. [defaultbandlimit="hard"
]
- Returns
the tuple (theta, xi_p, xi_m), 1-d NumPy arrays for the angular separation theta and the two shear correlation functions.
-
getConvergence
(pos, units=coord.arcsec, periodic=False)[source]¶ This function can interpolate between grid positions to find the convergence values for a given list of input positions (or just a single position). Before calling this function, you must call
buildGrid
first to define the grid of convergences on which to interpolate. The docstring forbuildGrid
provides some guidance on appropriate grid configurations to use when building a grid that is to be later interpolated to random positions.Note that the interpolation (specified when calling
buildGrid
) modifies the effective 2-point functions of these quantities. See docstring for getShear() docstring for caveats about interpolation. The user is advised to be very careful about deviating from the default Lanczos-5 interpolant.The usage of getConvergence() is the same as for getShear(), except that it returns only a single quantity (convergence value or array of convergence values) rather than two quantities. See documentation for getShear() for some examples.
- Parameters
pos –
Position(s) of the source(s), assumed to be post-lensing! Valid ways to input this:
single PositionD (or PositionI) instance
tuple of floats: (x,y)
list or array of PositionD (or PositionI) instances
tuple of lists/arrays: ( xlist, ylist )
units – The angular units used for the positions. [default: arcsec]
periodic – Whether the interpolation should treat the positions as being defined with respect to a periodic grid, which will wrap them around if they are outside the bounds of the original grid on which shears and convergences were defined. If not, then convergences are set to zero for positions outside the original grid. [default: False]
- Returns
the convergence, kappa (either a scalar or a numpy array)
If the input
pos
is given a single position, kappa is the convergence value. If the inputpos
is given a list/array of positions, kappa is a NumPy array.
-
getLensing
(pos, units=coord.arcsec, periodic=False)[source]¶ This function can interpolate between grid positions to find the lensing observable quantities (reduced shears g1 and g2, and magnification mu) for a given list of input positions (or just a single position). Before calling this function, you must call
buildGrid
first to define the grid of shears and convergences on which to interpolate. The docstring forbuildGrid
provides some guidance on appropriate grid configurations to use when building a grid that is to be later interpolated to random positions.Note that the interpolation (specified when calling
buildGrid
) modifies the effective 2-point functions of these quantities. See docstring for getShear() docstring for caveats about interpolation. The user is advised to be very careful about deviating from the default Lanczos-5 interpolant.The usage of getLensing() is the same as for getShear(), except that it returns three quantities (two reduced shear components and magnification) rather than two. See documentation for getShear() for some examples.
- Parameters
pos –
Position(s) of the source(s), assumed to be post-lensing! Valid ways to input this:
single PositionD (or PositionI) instance
tuple of floats: (x,y)
list/array of PositionD (or PositionI) instances
tuple of lists/arrays: ( xlist, ylist )
units – The angular units used for the positions. [default: arcsec]
periodic – Whether the interpolation should treat the positions as being defined with respect to a periodic grid, which will wrap them around if they are outside the bounds of the original grid on which shears and convergences were defined. If not, then shear is set to zero and magnification is set to 1 for positions outside the original grid. [default: False]
- Returns
shear and magnification as a tuple (g1,g2,mu).
If the input
pos
is given a single position, the return values are the shear and magnification values at that position. If the inputpos
is given a list/array of positions, they are NumPy arrays.
-
getMagnification
(pos, units=coord.arcsec, periodic=False)[source]¶ This function can interpolate between grid positions to find the lensing magnification (mu) values for a given list of input positions (or just a single position). Before calling this function, you must call
buildGrid
first to define the grid of shears and convergences on which to interpolate. The docstring forbuildGrid
provides some guidance on appropriate grid configurations to use when building a grid that is to be later interpolated to random positions.Note that the interpolation (specified when calling
buildGrid
) modifies the effective 2-point functions of these quantities. See docstring for getShear() docstring for caveats about interpolation. The user is advised to be very careful about deviating from the default Lanczos-5 interpolant.The usage of getMagnification() is the same as for getShear(), except that it returns only a single quantity (a magnification value or array of magnification values) rather than a pair of quantities. See documentation for getShear() for some examples.
- Parameters
pos –
Position(s) of the source(s), assumed to be post-lensing! Valid ways to input this:
single PositionD (or PositionI) instance
tuple of floats: (x,y)
list/array of PositionD (or PositionI) instances
tuple of lists/arrays: ( xlist, ylist )
units – The angular units used for the positions. [default: arcsec]
periodic – Whether the interpolation should treat the positions as being defined with respect to a periodic grid, which will wrap them around if they are outside the bounds of the original grid on which shears and convergences were defined. If not, then magnification is set to 1 for positions outside the original grid. [default: False]
- Returns
the magnification, mu (either a scalar or a numpy array)
If the input
pos
is given a single position, mu is the magnification value. If the inputpos
is given a list/array of positions, mu is a NumPy array.
-
getShear
(pos, units=coord.arcsec, reduced=True, periodic=False)[source]¶ This function can interpolate between grid positions to find the shear values for a given list of input positions (or just a single position). Before calling this function, you must call
buildGrid
first to define the grid of shears and convergences on which to interpolate. The docstring forbuildGrid
provides some guidance on appropriate grid configurations to use when building a grid that is to be later interpolated to random positions.By default, this method returns the reduced shear, which is defined in terms of shear and convergence as reduced shear
g=gamma/(1-kappa)
; thereduced
keyword can be set to False in order to return the non-reduced shear.Note that the interpolation (specified when calling
buildGrid
) modifies the effective shear power spectrum and correlation function somewhat, though the effects can be limited by careful choice of grid parameters (see buildGrid() docstring for details). Assuming those guidelines are followed, then the shear correlation function modifications due to use of the quintic, Lanczos-3, and Lanczos-5 interpolants are below 5% on all scales from the grid spacing to the total grid extent, typically below 2%. The linear, cubic, and nearest interpolants perform significantly more poorly, with modifications of the correlation functions that can reach tens of percent on the scales where the recommended interpolants perform well. Thus, the default interpolant is Lanczos-5, and users should think carefully about the acceptability of significant modification of the shear correlation function before changing to use linear, cubic, or nearest.Users who wish to ensure that the shear power spectrum is preserved post-interpolation should consider using the
periodic
interpolation option, which assumes the shear field is periodic (i.e., the sky is tiled with many copies of the given shear field). Those who care about the correlation function should not use this option, and for this reason it’s not the default.Some examples of how to use getShear():
Get the shear for a particular point:
>>> g1, g2 = my_ps.getShear(pos = galsim.PositionD(12, 412))
This time the returned values are just floats and correspond to the shear for the provided position.
You can also provide a position as a tuple to save the explicit PositionD construction:
>>> g1, g2 = my_ps.getShear(pos = (12, 412))
Get the shears for a bunch of points at once:
>>> xlist = [ 141, 313, 12, 241, 342 ] >>> ylist = [ 75, 199, 306, 225, 489 ] >>> poslist = [ galsim.PositionD(xlist[i],ylist[i]) for i in range(len(xlist)) ] >>> g1, g2 = my_ps.getShear( poslist ) >>> g1, g2 = my_ps.getShear( (xlist, ylist) )
Both calls do the same thing. The returned g1, g2 this time are numpy arrays of g1, g2 values. The arrays are the same length as the number of input positions.
- Parameters
pos –
Position(s) of the source(s), assumed to be post-lensing! Valid ways to input this:
single PositionD (or PositionI) instance
tuple of floats: (x,y)
list/array of PositionD (or PositionI) instances
tuple of lists/arrays: ( xlist, ylist )
units – The angular units used for the positions. [default: arcsec]
reduced – Whether returned shear(s) should be reduced shears. [default: True]
periodi – Whether the interpolation should treat the positions as being defined with respect to a periodic grid, which will wrap them around if they are outside the bounds of the original grid on which shears were defined. If not, then shears are set to zero for positions outside the original grid. [default: False]
- Returns
the shear as a tuple, (g1,g2)
If the input
pos
is given a single position, (g1,g2) are the two shear components. If the inputpos
is given a list/array of positions, they are NumPy arrays.
NFW Halo Shears¶
-
class
galsim.
NFWHalo
(mass, conc, redshift, halo_pos=galsim.PositionD(x=0.0, y=0.0), omega_m=None, omega_lam=None, cosmo=None)[source]¶ Class for NFW halos.
Compute the lensing fields shear and convergence of a spherically symmetric NFW halo of given mass, concentration, redshift, assuming Cosmology. No mass-concentration relation is employed.
Based on Matthias Bartelmann’s libastro.
The cosmology to use can be set either by providing a Cosmology instance as cosmo, or by providing omega_m and/or omega_lam. If only one of the latter is provided, the other is taken to be one minus that. If no cosmology parameters are set, a default Cosmology is constructed.
- Parameters
mass – Mass defined using a spherical overdensity of 200 times the critical density of the universe, in units of M_solar/h.
conc – Concentration parameter, i.e., ratio of virial radius to NFW scale radius.
redshift – Redshift of the halo.
halo_pos – Position of halo center (in arcsec). [default: PositionD(0,0)]
omega_m – Omega_matter to pass to Cosmology constructor. [default: None]
omega_lam – Omega_lambda to pass to Cosmology constructor. [default: None]
cosmo – A Cosmology instance. [default: None]
-
getConvergence
(pos, z_s, units=coord.arcsec)[source]¶ Calculate convergence of halo at specified positions.
- Parameters
pos –
Position(s) of the source(s), assumed to be post-lensing! Valid ways to input this:
single PositionD (or PositionI) instance
tuple of floats: (x,y)
list/array of PositionD (or PositionI) instances
tuple of lists/arrays: ( xlist, ylist )
z_s – Source redshift(s).
unit – Angular units of coordinates (only arcsec implemented so far). [default: galsim.arcsec]
- Returns
the convergence, kappa
If the input
pos
is given a single position, kappa is the convergence value. If the inputpos
is given a list/array of positions, kappa is a NumPy array.
-
getLensing
(pos, z_s, units=coord.arcsec)[source]¶ Calculate lensing shear and magnification of halo at specified positions.
- Parameters
pos –
Position(s) of the source(s), assumed to be post-lensing! Valid ways to input this:
single PositionD (or PositionI) instance
tuple of floats: (x,y)
list/array of PositionD (or PositionI) instances
tuple of lists/arrays: ( xlist, ylist )
z_s – Source redshift(s).
units – Angular units of coordinates (only arcsec implemented so far). [default: galsim.arcsec]
- Returns
the reduced shears and magnifications as a tuple (g1,g2,mu)
If the input
pos
is given a single position, the return values are the shear and magnification values at that position. If the inputpos
is given a list/array of positions, they are NumPy arrays.
-
getMagnification
(pos, z_s, units=coord.arcsec)[source]¶ Calculate magnification of halo at specified positions.
- Parameters
pos –
Position(s) of the source(s), assumed to be post-lensing! Valid ways to input this:
single PositionD (or PositionI) instance
tuple of floats: (x,y)
list/array of PositionD (or PositionI) instances
tuple of lists/arrays: ( xlist, ylist )
z_s – Source redshift(s).
units – Angular units of coordinates (only arcsec implemented so far). [default: galsim.arcsec]
- Returns
the magnification mu
If the input
pos
is given a single position, mu is the magnification value. If the inputpos
is given a list/array of positions, mu is a NumPy array.
-
getShear
(pos, z_s, units=coord.arcsec, reduced=True)[source]¶ Calculate (reduced) shear of halo at specified positions.
- Parameters
po –
Position(s) of the source(s), assumed to be post-lensing! Valid ways to input this:
single PositionD (or PositionI) instance
tuple of floats: (x,y)
list/array of PositionD (or PositionI) instances
tuple of lists/arrays: ( xlist, ylist )
z_s – Source redshift(s).
units – Angular units of coordinates (only arcsec implemented so far). [default: galsim.arcsec]
reduced – Whether returned shear(s) should be reduced shears. [default: True]
- Returns
the (possibly reduced) shears as a tuple (g1,g2)
If the input
pos
is given a single position, (g1,g2) are the two shear components. If the inputpos
is given a list/array of positions, they are NumPy arrays.
-
class
galsim.
Cosmology
(omega_m=0.3, omega_lam=0.7)[source]¶ Basic cosmology calculations.
Cosmology calculates expansion function E(a) and angular diameter distances Da(z) for a LambdaCDM universe. Radiation is assumed to be zero and Dark Energy constant with w = -1 (no quintessence), but curvature is arbitrary.
Based on Matthias Bartelmann’s libastro.
- Parameters
omega_m – Present day energy density of matter relative to critical density. [default: 0.3]
omega_lam – Present day density of Dark Energy relative to critical density. [default: 0.7]
Power Spectrum Estimation¶
-
class
galsim.pse.
PowerSpectrumEstimator
(N=100, sky_size_deg=10.0, nbin=15)[source]¶ Class for estimating the shear power spectrum from gridded shears.
The PowerSpectrumEstimator class can be used even on systems where GalSim is not installed. It just requires NumPy.
This class stores all the data used in power spectrum estimation that is fixed with the geometry of the problem - the binning and spin weighting factors.
The only public method is estimate(), which is called with 2D
g1
andg2
arrays on a square grid. It assumes the flat sky approximation (whereell
andk
are interchangeable), and rebins the observed ell modes into a user-defined number of logarithimic bins in ell. Given that the grid parameters are precomputed and stored when thePowerSpectrumEstimator
is initialized, computation of the PS for multiple sets of shears corresponding to the same grid setup can proceed more rapidly than if everything had to be recomputed each time.Below is an example of how to use this code (relying on GalSim to provide the arrays of g1 and g2, though that is by no means required, and assuming that the user is sitting in the examples/ directory):
>>> grid_size = 10. # Define the total grid extent, in degrees >>> ngrid = 100 # Define the number of grid points in each dimension: (ngrid x ngrid) >>> n_ell = 15 # Choose the number of logarithmic bins in ell or k for outputs >>> >>> # Define a lookup-table for the power spectrum as a function of k based on the outputs >>> # of iCosmo (see demo11.py for more description of how this was generated). >>> my_tab = galsim.LookupTable(file='data/cosmo-fid.zmed1.00.out') >>> >>> # Generate a galsim.PowerSpectrum with this P(k), noting the units. >>> my_ps = galsim.PowerSpectrum(my_tab, units=galsim.radians) >>> >>> # Build a grid of shear values with the desired parameters. >>> g1, g2 = my_ps.buildGrid(grid_spacing=grid_size/ngrid, ngrid=ngrid, ... units=galsim.degrees) >>> >>> # Initialize a PowerSpectrumEstimator with the chosen grid geometry and number of ell >>> # bins. Note that these values are actually the default, so we didn't technically have >>> # to specifythem. >>> my_pse = galsim.pse.PowerSpectrumEstimator(ngrid, grid_size, n_ell) >>> >>> # Estimate the power based on this set of g1, g2. If we get another set of shears for >>> # the same grid geometry, we can reuse the same PowerSpectrumEstimator object. >>> ell, P_e, P_b, P_eb = my_pse.estimate(g1, g2)
The output NumPy arrays
ell
,P_e
,P_b
, andP_eb
contain the effective ell value, the E-mode auto-power spectrum, the B-mode auto-power spectrum, and the EB cross-power spectrum. The units are inverse radians for ell, and radians^2 for the output power spectra.Some important notes:
1) Power spectrum estimation requires a weight function which decides how the averaging is done across ell within each bin. By default that weighting is flat in ell using an analytic calculation of the area in ell space, but this is easy to change with the
_bin_power
function. (Note this area averaged bin weighting is only approximate for the higher frequency bins in which the lowerell
edge is greater thanpi * ngrid / grid_size
, due to the annularell
region being cut off by the square grid edges beyond this value.) A keyword allows for weighting by the power itself, but use of this functionality requires the GalSim software package.2) This is the power spectrum of the gridded data, not the underlying field - we do not account for the effects of the finite grid (basically, ignoring all the reasons why power spectrum estimation is hard - see devel/modules/lensing_engine.pdf in the GalSim repository). Users must account for the contribution of noise in
g1
,g2
and any masking.The binning is currently fixed as uniform in log(ell).
4) The code for this class uses the notation of the GREAT10 handbook (Kitching et al. 2011, http://dx.doi.org/10.1214/11-AOAS484), equations 17-21.


Many medicines only relieve pain, (paracetamol/aspirin); it is your immune system that kills pathogens and cures you.
Disinfectants and antiseptics kill bacteria outside the body (e.g. in toilets and on kitchen surfaces), but are too strong to use inside the body.
Antibiotics (e.g. penicillin, discovered in mould by Alexander Fleming) kill or inhibit the bacteria that cause a number of diseases, but are useless against viral (virus-based) pathogens, which get directly into our cells. (OCR/Edexcel: There are also antifungals that kill fungi.)
Examiner’s tip: “Remember the difference between antibodies (Section 1.3) and antibiotics. Use these terms carefully.”
Specific antibiotics are used to kill specific bacteria. Yet some bacteria become resistant to almost all antibiotics, by chance mutation/variation of their genetic make-up.
Bacteria in our bodies that are making us ill may sometimes mutate at random, in small numbers:If we are taking antibiotics for our illness and continue to do so, these slightly different bacteria, variant B, may still be killed. If we stop taking antibiotics because we feel better, the bacteria may survive and multiply. If they are on our skin we may spread them to other people, too:The whole process may repeat again later: bacteria B may by chance mutate again to become strain C. This new strain may then multiply quickly when it meets no or ineffective resistance from antibiotics:
If bacteria become increasingly resistant to antibiotics – when people take antibiotics they don’t really need, or do not finish a full course of antibiotics – ‘superbugs’ like MRSA can develop.
MRSA is highly resistant to antibiotics, is often found in hospitals, and causes hundreds of deaths per year. Doctors washing their hands between treating different patients helps reduce its spread (see Section 1.3 about Doctor Semmelweiss).
Scientists are studying new sources of possible antibiotics, e.g. different moulds, crocodile blood and honey.
Vaccines and immunity
Vaccination (also called immunisation) involves putting a small amount of dead or inactive pathogen into the body, often by injection.

The memory cells left over from this process will respond to the pathogen in the same way if a real infection occurs. This time, antibodies will be produced more quickly. The disease never takes hold: you are immune.
Vaccines work against both bacterial pathogens (e.g. tetanus) and viral pathogens (e.g. measles and mumps).
Some viruses like the flu mutate so easily that epidemics (in a single country) or pandemics (international) result, e.g. swine flu in 2009.
In the 1970s the whooping cough vaccine was wrongly linked by a small study to brain damage in children. The original scary story carried more weight in the media than later evidence that the study was flawed. Vaccination took many years to return to its previous levels: more children died than should have.
No vaccine can be guaranteed 100% safe. There is often a tiny risk of side effects with some vaccines, affecting a very small number of people. This can make parental choice about whether to vaccinate difficult.
Overall, vaccines against (for example) smallpox have saved millions of lives in recent decades. To be effective, ideally everyone in a population should be vaccinated.
Investigating bacteria (AQA)
We culture (grow) microorganisms, especially bacteria, to investigate how they are affected by antibiotics.
Agar jelly is a culture medium that provides nutrients (carbohydrates and minerals) for the microorganisms.
Cultures must be prepared carefully: they must be uncontaminated from other microbes in air, water, our skin. They also need oxygen and warmth
We sterilize the agar itself, the petri dishes and the loops used to transfer the bacteria to the agar; autoclave ovens (high pressure steam), gamma rays and UV light can also be used.
We keep cultures at a temperature lower than the human body’s (37°C) to reduce the risk of them entering our bodies. We can still investigate bacteria at lower temperatures.


I am Joachim, a software engineer, solution architect & technology evangelist working at Baloise Group.
I am passionate about
I formerly worked for Zühlke, Badenova and Endress+Hauser. I have a Bachelor’s degree in Business Information Systems from Furtwangen University, with a semester abroad in Perth, Western Australia at Murdoch University.
I am based in Muellheim / Germany.
©2021 Joachim Prinzbach - Split Template by One Page Love