1 / 11

Data input

Data input. DATA_SECTION. Defines variables to read data from file (*.dat) Defines variables that will be constant in the model – no derivative values calculated for these variables int = integer number = floating point ivector = one dimensional array of integers

buchholtz
Télécharger la présentation

Data input

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Data input

  2. DATA_SECTION • Defines variables to read data from file (*.dat) • Defines variables that will be constant in the model – no derivative values calculated for these variables int = integer number = floating point ivector = one dimensional array of integers vector = one dimensional array of numbers imatrix = two dimensional array of integers matrix = two dimensional array of numbers 3darray = three dimensional array of numbers 4darray = four dimensional array of numbers …… • init_ prefix = read in data from file

  3. DATA_SECTION init_int Nobs init_vector X(1,Nobs) *.dat file 5 2 5 8 3 6

  4. DATA_SECTION init_int Nobs init_int StartYear init_int EndYear init_matrix(1,Nobs,StartYear,EndYear) *.dat file 3 1991 2000 34 15 67 81 89 45 76 98 45 43 38 54 19 24 34 75 14 75 97 12 74 13 44 38 48 41 85 15 19 72 Second dimension First dimension

  5. DATA_SECTION init_int Nages init_int Nobs init_3darray(1,2,1,Nages,1,Nobs) *.dat file 3 5 34 15 67 81 89 38 54 19 24 34 74 13 44 38 48 45 76 98 45 43 75 14 75 97 12 41 85 15 19 72 Third dimension Second dimension First dimension 1 First dimension 2

  6. Ragged arrays DATA_SECTION init_int Npops init_ivector Start_Year(1,Npops) init_ivector End_Year(1,Npops) init_matrix Catch(1,Npops,StartYear,EndYear) *.dat file 2 1991 1995 2000 1999 23 5 54 12 45 8 23 45 76 32 45 34 32 54 34

  7. C++ code: for manipulating data • Done only once • Block of code LOCAL _CALCS x(1)=3; x(2)=7; END_CALCS • Single line !!x(1)=3;

  8. Changing file names • Command line option “-ind filename“ • In the DATA_SECTION !!ad_comm::change_datafile_name("seed.dat");

  9. Format for general models DATA_SECTION init_int Nobs init_matrix Abundance(1,Nobs,1,3) *.dat file #Year, value, sd 1975 23 5 1977 19 4 1985 8 2 …..

  10. Data manipulation: indexing array components DATA_SECTION init_int nobs init_matrix Obs(1,nobs,1,10) vector Ob1(1,10) vector Ob1_56a(5,6) vector Ob1_56b(5,6) !!Ob1=Obs(1); LOCAL_CALCS OB1_56a=Ob1(5,6) OB1_56b=Obs(1)(5,6) END_CALCS

  11. Column extraction DATA SECTION init_int nobs init_matrix Obs(1,nobs,1,2) vector Y(1,nobs) vector x(1,nobs) PRELIMINARY CALCS SECTION Y=column(Obs,1); // extract the first column x=column(Obs,2); // extract the second column

More Related