Join Now

Nereus Tutorial - Searching for Pulsars

This tutorial shows how to build a simple Nereus application. Slightly more complex than a "Hello World" starting point, the task is to scan through some data files to detect pulsars. Each data file represents the signal recorded by a radio telescope when pointed in a particular direction in the sky for a few minutes. We are trying to work out whether there is a pulsar in that direction by processing this data.

The steps necessary to process each data file are:

  1. Guess an inversion parameter - called dispersion measure.
  2. Invert the data with the value guessed above.
  3. Report the signal-to-noise (S/N) ratio corresponding to this guessed value.
  4. Repeat the above steps until all reasonable values of dispersion have been tried.

If a pulsar is present there will be a peak in the S/N ratios found above at the correct dispersion measure.

Stage 1

Download the Java source and data files for stage 1 here. Unzip this to a directory, compile and run the SKADedisperse.java (JDK 1.6 is assumed to be installed). Note that Nereus is not needed at this stage, the code is just a stand-alone Java program.

unzip stage1.zip
javac SKADedisperse.java
java SKADedisperse

SKADedisperse downloads data files from the internet one at a time and tries a series of dedispersion measures (0,1,2,3...200) for each, printing the S/N ratio out to the console.

As Nereus does not provide access to the local file system (for security reasons) Nereid code needs to read/write via HTTP to remote servers (in this case www-nereus.physics.ox.ac.uk).

Stage 2

Download the files for stage 2 here and unzip as before. Compilation this time needs the Nereus Server jar file (Nereus.jar) which can be obtained from the downloads page:

unzip stage2.zip

// For Windows Command Shell/Cygwin - use semicolons
javac -cp ".;Nereus.jar" *.java 
java -cp ".;Nereus.jar" AstroServer

// For Linux/Unix - use colons
javac -cp ".:Nereus.jar" *.java 
java -cp ".:Nereus.jar" AstroServer

This will start a server on your machine, listening on port 8080. You should be able to browse to the main status page with the following link http://localhost:8080/

Now your application server is running, you can try it out with the Nereus Frame developer tool, available here. Start the tool at a command prompt as follows:

java -jar NereusFrame.jar http://localhost:8080/Astro.nml

And you should see a window like the first figure below. Right-click on this window and select the "show console" option to see some diagnostics about the top level "container" into which the Astro.nml text file was downloaded (second figure). Right-click again, select the "view" submenu, and click on the "test" service to see the output from the Astrophysics processing code (third figure).

Refresh the main status page of your Astro server and it should show that a data file is currently being processed by your Nereid code (inside the NereusFrame tool). When 200 dispersion measures have been processed for a particular file, the results are uploaded and can be viewed by clicking the file name on the main status page.

To repeat the run stop the Application server, delete the "output" folder which was created in the directory where you ran it and start it again. Do this now before starting stage 3.

Stage 3

With the application specific Nereid and Server now working, we can now make it work through a Nereus Server. For testing, start a Nereus server on your local machine (using the Nereus.jar downloaded above) as follows:

java -jar Nereus.jar -domain localhost -port 8090

This makes the server listen on port 8090 instead of the default web port (port 80), and also ensures all clients get the correct name (localhost in this case) to look up their server when querying their DNS servers.

Note: It is good practice to register a domain name in a public DNS registry for both your application and nereus servers. This means all your Nereids will correctly find your application server when they query their local DNS server, similarly your Nereus clients may encounter difficulties if they can't find your Nereus server via DNS. At Oxford we use nereus.ox.ac.uk.

With your Nereus server running locally, open a browser and browse to its main page. Click on the "Open Nereus Web Start" link and a Nereus client should start (the window should look identical to the NereusFrame tool in stage 2). Wait for the client to log into your server - check that a valid URL is displayed in the lower left hand side of the window.

Looking back at your web browser, click on the Server Status link on the main page of your Nereus server, and then on the link to your client (most likely NC00000000).

Now we create a container to hold your Astrophysics Nereid - a single Nereus client can have many containers and sub-containers; much like a file/directory hierarchy. Choose a name (e.g. "Astro"), enter this in the box on the left and then enter a URL for the NML file. As it's a URL it can be anywhere on the internet, but in this case the NML comes from your local Application server:

http://localhost:8080/Astro.nml

Click the "Create Container" button and watch your Nereus client to see your service created and your Astrophysics processing commence.

Stage 4

You are now ready to deploy your Nereid code out onto the Nereus cloud, and a simple way is to create an account. Now install your Nereus server ensuring the machine running it is visible to the public internet and has a public domain name (DNS queries report your server's IP address). Also make sure your application server is visible and registered in the DNS.

Note: If you're just testing within a local network and your Nereus server is not externally visible on the internet, all that is required is that the client machines can see your server over the LAN. In this case you can't use Nereus Cloud, but you can manually install Nereids on each client machine by repeating the steps in stage 3 above.

Now log into your Nereus Cloud account, and enter a container name and URL as in step 3 (replacing references to "localhost" with the domain name of your Application Server). All clients connected through your Nereus server will then download your Astrophysics processing code and run in parallel - the more machines which join by clicking the link on your Nereus server's homepage the faster the job will complete.