The Madrigal database is used throughout the space science community to distribute data on Earth's upper atmosphere. Built into the Madrigal database is a derivation engine that can calculate many additional scientific parameters besides those stored in the underlying data files. The student will assist the team with adding new parameters to the Madrigal database engine, selected from a list most often requested by the space science community. The work will be done in the Unix operating system framework and in the C software language. While familiarity with these tools is a plus, the student will have the opportunity to learn them as part of the project. The student will also gain familiarity with basic data analysis concepts such as curve fitting and data retrieval. A desire to learn about computer or software engineering and their practices is helpful.

Project milestones

  1. Work through C tutorial

  2. Learn to compile and debug C code using eclipse

  3. Understand the problem - how to derive NMAX and HMAX from ISR radar data and calculate error

  4. Learn code documentation

  5. Code and test example problems

  6. Write a test code that calls the derived method - uses hard coded radar data with real error bars

  7. Write the simplest possible approach - return the peak point. Test in framework above.

  8. Learn about curve fitting.

  9. Search for pre-existing curve fitting code written in C

  10. Modify the test code to use a curve fitting approach

  11. Integrate new method into Madrigal and test

Excercise 1: Reading and modifying a double array

Write a C program that does the following:

  1. Declare an array of 10 doubles and sets them to 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 14.5, 13.5, 12.5, 11.5

  2. Has a function called "doubleArray" that inputs a double array, and then doubles every value. The function returns void.

  3. Has a function called "getHighest" that inputs a double array, and returns the largest double in the array.

  4. In the main method:

    1. Call getHighest, then print "The highest is %f\n" with that value

    2. Call doubleArray

    3. Call getHighest, then print "The highest is now %f\n" with that value

Excercise 2: Working with a multidimensional double array

Write a C program that does the following:

  1. Declare an array of doubles with 3 rows and 10 columns. You choose the values.

  2. Has a function called "double2DArray" that inputs a two dimensional double array, and then doubles every value. The function declaration is:

    void double2DArray(double * array, int numRows, int numCols)
  3. Has a function called "getHighestInRow" that inputs a two dimensional double array, and returns the largest double in the array from one particular row. The function declaration is:

    double getHighestInRow(double * array, int numRows, int numCols, int rowNum)
  4. In the main method:

    1. Loop through each row. Call getHighestInRow, then print "The highest in row %i is %f\n" with that value.

    2. Call double2DArray

    3. Repeat the first step to print out the new highest values.

  5. Change the program to have 4 rows and 11 columns. How could you change the program so that its easy to change the size of the double array?

Excercise 3: Working with structs and arrays

Write a C program that does the following:

  1. Define a struct called address as follows:

    struct address 
    { 
        char name[40];
        char street[50];
        char city[40];
        char state[2];
        int zip;
    }
  2. Add a function called printAddresses. It's declaration will be

    void printAddresses(struct address addrArray[], int count);

    It will print all the addresses in an array of struct address as follows:

    Address number 0:
        Name: Bill Rideout
        Street: South Harbor Road
        City: Townsend
        State: MA
        Zip: 01469
    Address number 1:
        and so on...
  3. In the main method:

    1. Create an array of four "struct address": struct address addrArray[4];

    2. Set all the values in the four addresses.

    3. Call printAddresses

Excercise 4: Working with strings

Write a C program that is similar to Exercise 3, except this time it will only print the address of the name requested:

  1. Define the same struct called address as follows:

    struct address 
    { 
        char name[40];
        char street[50];
        char city[40];
        char state[2];
        int zip;
    }
  2. Add a function called printAddress. It's declaration will be

    void printAddress(struct address addr);

    It will print a single struct address as follows:

    Name: Bill Rideout
        Street: South Harbor Road
        City: Townsend
        State: MA
        Zip: 01469
  3. Add a function called findAddress. It's declaration will be

    int findAddress(struct address addrArray[], int count, char * name);

    This method will return the index of addrArray where address.name matches name. You will need to use the strcmp method to test whether the names match. If you find a match, return the index of addrArray where the names match. If you don't find a match, return -1.

  4. In the main method:

    1. print "Please input a name to search for: "

    2. scanf the input name into a string. You will need to use strcpy

    3. Create an array of four "struct address": struct address addrArray[4];

    4. Set all the values in the four addresses.

    5. Call findAddress to see if you have a match.

    6. If you do, call printAddress(addrArray[index]) where index is the index returned by findAddress.

    7. If there is no match, print "Sorry, no matches found!"

Excercise 5: Working with files

Write a C program that is similar to Exercise 4, except this time it reads names to be looked up from one file, and writes the address to another file. To write this program, you will need to know fopen, fclose, scanf, fgets, and fputs.

  1. Create a text file that has one name per line. For example:

    Bill Rideout
    Jenipher Danline Gonzalez Aponte
    Barack Obama

Some of the names should match the names in your code, and at least one should not match.

  1. Define the same struct called address as follows:

    struct address 
    { 
        char name[40];
        char street[50];
        char city[40];
        char state[2];
        int zip;
    }
  2. Add a function called writeAddress. It's declaration will be

    void printAddress(FILE * fp, struct address addr);

    It will write a single struct address as follows to an open writable file:

        Name: Bill Rideout
        Street: South Harbor Road
        City: Townsend
        State: MA
        Zip: 01469
  3. Reuse the function called findAddress from Exercise 4. It's declaration will be

    int findAddress(struct address addrArray[], int count, char * name);

    This method will return the index of addrArray where address.name matches name. If you find a match, return the index of addrArray where the names match. If you don't find a match, return -1.

  4. In the main method:

    1. print "Please input the name of the file with the names to use: "

    2. scanf the input name into a string. You will need to use strcpy

    3. print "Please input the name of the output file where the addresses will be written: "

    4. scanf the output file name into a string. You will need to use strcpy

    5. Create an array of four "struct address": struct address addrArray[4];

    6. Set all the values in the four addresses.

    7. Open the input file with names for reading.

    8. Open the output file for writing.

    9. Loop through all the names in the input file. For each name:

      1. Call findAddress to see if you have a match.

      2. If you do, call writeAddress(fp, addrArray[index]) where index is the index returned by findAddress.

      3. If there is no match, do not write anything to the output file.

    10. Close both files at the end.

Project 1: Add parameter JULIAN_DATE

The goal of this project is to add a new time parameter to Madrigal, JULIAN_DATE. This method gives the average time of a Madrigal record as a Julian date. A Julian date is defined to be the number of days elapsed since noon on January 1, 4713 BCE. Following the astronomical convention, a Julian day is defined to start at 12pm (noon).

Madrigal already has a parameter called JDAYNO, which gives the Julian day number. But this number only tells you what day it is. JULIAN_DATE is a float, so it tells you what time it is to a second. This way of telling time is used by the programming language "IDL", so IDL users might like having this parameter.

Steps:

  1. Read about the needed steps in Extending Derivation Methods

  2. Look through the file in madroot/source/madc: include/madDeriveMethods.h, madrec/madDeriveMethods.c, madrec/madDeriveEngine.c for an example. In particular, look at the example that has JDAYNO. You will be creating your own code that is similar to this code.

  3. Learn how to recompile Madrigal when you change some code. The basic procedure is to copy the files on to your Madrigal installation, and then cd to $MADROOT/source/madc/madrec, and then run make install.

  4. Learn how to run isprint so that you can test your changes.

  5. Find some other way of calculating JULIAN DATE so you can test your result. Look on the web, or try using IDL.

 

  • No labels