diff --git a/pred_src/CMakeFiles/CMakeDirectoryInformation.cmake b/pred_src/CMakeFiles/CMakeDirectoryInformation.cmake new file mode 100644 index 0000000..c7fc8e0 --- /dev/null +++ b/pred_src/CMakeFiles/CMakeDirectoryInformation.cmake @@ -0,0 +1,23 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.6 + +# Relative path conversion top directories. +SET(CMAKE_RELATIVE_PATH_TOP_SOURCE "/var/hab/cusf-landing-prediction") +SET(CMAKE_RELATIVE_PATH_TOP_BINARY "/var/hab/cusf-landing-prediction") + +# Force unix paths in dependencies. +SET(CMAKE_FORCE_UNIX_PATHS 1) + +# The C and CXX include file search paths: +SET(CMAKE_C_INCLUDE_PATH + "/usr/include/glib-2.0" + "/usr/lib/glib-2.0/include" + ) +SET(CMAKE_CXX_INCLUDE_PATH ${CMAKE_C_INCLUDE_PATH}) +SET(CMAKE_Fortran_INCLUDE_PATH ${CMAKE_C_INCLUDE_PATH}) + +# The C and CXX include file regular expressions for this directory. +SET(CMAKE_C_INCLUDE_REGEX_SCAN "^.*$") +SET(CMAKE_C_INCLUDE_REGEX_COMPLAIN "^$") +SET(CMAKE_CXX_INCLUDE_REGEX_SCAN ${CMAKE_C_INCLUDE_REGEX_SCAN}) +SET(CMAKE_CXX_INCLUDE_REGEX_COMPLAIN ${CMAKE_C_INCLUDE_REGEX_COMPLAIN}) diff --git a/pred_src/CMakeFiles/pred.dir/C.includecache b/pred_src/CMakeFiles/pred.dir/C.includecache new file mode 100644 index 0000000..380b44b --- /dev/null +++ b/pred_src/CMakeFiles/pred.dir/C.includecache @@ -0,0 +1,616 @@ +#IncludeRegexLine: ^[ ]*#[ ]*(include|import)[ ]*[<"]([^">]+)([">]) + +#IncludeRegexScan: ^.*$ + +#IncludeRegexComplain: ^$ + +/usr/include/glib-2.0/glib.h +glib/galloca.h +- +glib/garray.h +- +glib/gasyncqueue.h +- +glib/gatomic.h +- +glib/gbacktrace.h +- +glib/gbase64.h +- +glib/gbookmarkfile.h +- +glib/gcache.h +- +glib/gchecksum.h +- +glib/gcompletion.h +- +glib/gconvert.h +- +glib/gdataset.h +- +glib/gdate.h +- +glib/gdir.h +- +glib/gerror.h +- +glib/gfileutils.h +- +glib/ghash.h +- +glib/ghook.h +- +glib/giochannel.h +- +glib/gkeyfile.h +- +glib/glist.h +- +glib/gmacros.h +- +glib/gmain.h +- +glib/gmappedfile.h +- +glib/gmarkup.h +- +glib/gmem.h +- +glib/gmessages.h +- +glib/gnode.h +- +glib/goption.h +- +glib/gpattern.h +- +glib/gprimes.h +- +glib/gqsort.h +- +glib/gquark.h +- +glib/gqueue.h +- +glib/grand.h +- +glib/grel.h +- +glib/gregex.h +- +glib/gscanner.h +- +glib/gsequence.h +- +glib/gshell.h +- +glib/gslist.h +- +glib/gspawn.h +- +glib/gstrfuncs.h +- +glib/gstring.h +- +glib/gtestutils.h +- +glib/gthread.h +- +glib/gthreadpool.h +- +glib/gtimer.h +- +glib/gtree.h +- +glib/gtypes.h +- +glib/gunicode.h +- +glib/gurifuncs.h +- +glib/gutils.h +- +glib/gwin32.h +- + +/usr/include/glib-2.0/glib/galloca.h +glib/gtypes.h +- +alloca.h +- +malloc.h +- + +/usr/include/glib-2.0/glib/garray.h +glib/gtypes.h +- + +/usr/include/glib-2.0/glib/gasyncqueue.h +glib/gthread.h +- + +/usr/include/glib-2.0/glib/gatomic.h +glib/gtypes.h +- + +/usr/include/glib-2.0/glib/gbacktrace.h +glib/gtypes.h +- + +/usr/include/glib-2.0/glib/gbase64.h +glib/gtypes.h +- + +/usr/include/glib-2.0/glib/gbookmarkfile.h +glib/gerror.h +- +time.h +- + +/usr/include/glib-2.0/glib/gcache.h +glib/glist.h +- + +/usr/include/glib-2.0/glib/gchecksum.h +glib/gtypes.h +- + +/usr/include/glib-2.0/glib/gcompletion.h +glib/glist.h +- + +/usr/include/glib-2.0/glib/gconvert.h +glib/gerror.h +- + +/usr/include/glib-2.0/glib/gdataset.h +glib/gquark.h +- + +/usr/include/glib-2.0/glib/gdate.h +time.h +- +glib/gtypes.h +- +glib/gquark.h +- + +/usr/include/glib-2.0/glib/gdir.h +glib/gerror.h +- + +/usr/include/glib-2.0/glib/gerror.h +glib/gquark.h +- + +/usr/include/glib-2.0/glib/gfileutils.h +glib/gerror.h +- + +/usr/include/glib-2.0/glib/ghash.h +glib/gtypes.h +- +glib/glist.h +- + +/usr/include/glib-2.0/glib/ghook.h +glib/gmem.h +- + +/usr/include/glib-2.0/glib/giochannel.h +glib/gconvert.h +- +glib/gmain.h +- +glib/gstring.h +- + +/usr/include/glib-2.0/glib/gkeyfile.h +glib/gerror.h +- + +/usr/include/glib-2.0/glib/glist.h +glib/gmem.h +- + +/usr/include/glib-2.0/glib/gmacros.h +stddef.h +- + +/usr/include/glib-2.0/glib/gmain.h +glib/gslist.h +- +glib/gthread.h +- + +/usr/include/glib-2.0/glib/gmappedfile.h +glib/gerror.h +- + +/usr/include/glib-2.0/glib/gmarkup.h +stdarg.h +- +glib/gerror.h +- +glib/gslist.h +- + +/usr/include/glib-2.0/glib/gmem.h +glib/gslice.h +- +glib/gtypes.h +- + +/usr/include/glib-2.0/glib/gmessages.h +stdarg.h +- +glib/gtypes.h +- +glib/gmacros.h +- + +/usr/include/glib-2.0/glib/gnode.h +glib/gmem.h +- + +/usr/include/glib-2.0/glib/goption.h +glib/gerror.h +- +glib/gquark.h +- + +/usr/include/glib-2.0/glib/gpattern.h +glib/gtypes.h +- + +/usr/include/glib-2.0/glib/gprimes.h +glib/gtypes.h +- + +/usr/include/glib-2.0/glib/gqsort.h +glib/gtypes.h +- + +/usr/include/glib-2.0/glib/gquark.h +glib/gtypes.h +- + +/usr/include/glib-2.0/glib/gqueue.h +glib/glist.h +- + +/usr/include/glib-2.0/glib/grand.h +glib/gtypes.h +- + +/usr/include/glib-2.0/glib/gregex.h +glib/gerror.h +- +glib/gstring.h +- + +/usr/include/glib-2.0/glib/grel.h +glib/gtypes.h +- + +/usr/include/glib-2.0/glib/gscanner.h +glib/gdataset.h +- +glib/ghash.h +- + +/usr/include/glib-2.0/glib/gsequence.h +glib/gtypes.h +- + +/usr/include/glib-2.0/glib/gshell.h +glib/gerror.h +- + +/usr/include/glib-2.0/glib/gslice.h +glib/gtypes.h +- + +/usr/include/glib-2.0/glib/gslist.h +glib/gmem.h +- + +/usr/include/glib-2.0/glib/gspawn.h +glib/gerror.h +- + +/usr/include/glib-2.0/glib/gstrfuncs.h +stdarg.h +- +glib/gtypes.h +- + +/usr/include/glib-2.0/glib/gstring.h +glib/gtypes.h +- +glib/gunicode.h +- +glib/gutils.h +- + +/usr/include/glib-2.0/glib/gtestutils.h +glib.h +- + +/usr/include/glib-2.0/glib/gthread.h +glib/gerror.h +- +glib/gtypes.h +- +glib/gutils.h +- +glib/gatomic.h +- + +/usr/include/glib-2.0/glib/gthreadpool.h +glib/gthread.h +- + +/usr/include/glib-2.0/glib/gtimer.h +glib/gtypes.h +- + +/usr/include/glib-2.0/glib/gtree.h +glib/gnode.h +- + +/usr/include/glib-2.0/glib/gtypes.h +glibconfig.h +- + +/usr/include/glib-2.0/glib/gunicode.h +glib/gerror.h +- +glib/gtypes.h +- + +/usr/include/glib-2.0/glib/gurifuncs.h +glib.h +- + +/usr/include/glib-2.0/glib/gutils.h +glib/gtypes.h +- +stdarg.h +- + +/usr/include/glib-2.0/glib/gwin32.h +glib/gtypes.h +- + +/usr/lib/glib-2.0/include/glibconfig.h +glib/gmacros.h +- +limits.h +- +float.h +- + +/var/hab/cusf-landing-prediction/pred_src/altitude.c +stdio.h +- +stdlib.h +- +math.h +- +pred.h +/var/hab/cusf-landing-prediction/pred_src/pred.h +altitude.h +/var/hab/cusf-landing-prediction/pred_src/altitude.h +run_model.h +/var/hab/cusf-landing-prediction/pred_src/run_model.h + +/var/hab/cusf-landing-prediction/pred_src/altitude.h + +/var/hab/cusf-landing-prediction/pred_src/ini/dictionary.c +dictionary.h +/var/hab/cusf-landing-prediction/pred_src/ini/dictionary.h +stdio.h +- +stdlib.h +- +string.h +- +unistd.h +- + +/var/hab/cusf-landing-prediction/pred_src/ini/dictionary.h +stdio.h +- +stdlib.h +- +string.h +- +unistd.h +- + +/var/hab/cusf-landing-prediction/pred_src/ini/iniparser.c +ctype.h +- +iniparser.h +/var/hab/cusf-landing-prediction/pred_src/ini/iniparser.h + +/var/hab/cusf-landing-prediction/pred_src/ini/iniparser.h +stdio.h +- +stdlib.h +- +string.h +- +dictionary.h +/var/hab/cusf-landing-prediction/pred_src/ini/dictionary.h + +/var/hab/cusf-landing-prediction/pred_src/pred.c +stdio.h +- +stdlib.h +- +string.h +- +time.h +- +errno.h +- +ini/iniparser.h +/var/hab/cusf-landing-prediction/pred_src/ini/iniparser.h +util/gopt.h +/var/hab/cusf-landing-prediction/pred_src/util/gopt.h +wind/wind_file_cache.h +/var/hab/cusf-landing-prediction/pred_src/wind/wind_file_cache.h +run_model.h +/var/hab/cusf-landing-prediction/pred_src/run_model.h +pred.h +/var/hab/cusf-landing-prediction/pred_src/pred.h +altitude.h +/var/hab/cusf-landing-prediction/pred_src/altitude.h + +/var/hab/cusf-landing-prediction/pred_src/pred.h + +/var/hab/cusf-landing-prediction/pred_src/run_model.c +math.h +- +stdio.h +- +stdlib.h +- +assert.h +- +wind/wind_file.h +/var/hab/cusf-landing-prediction/pred_src/wind/wind_file.h +util/random.h +/var/hab/cusf-landing-prediction/pred_src/util/random.h +run_model.h +/var/hab/cusf-landing-prediction/pred_src/run_model.h +pred.h +/var/hab/cusf-landing-prediction/pred_src/pred.h +altitude.h +/var/hab/cusf-landing-prediction/pred_src/altitude.h + +/var/hab/cusf-landing-prediction/pred_src/run_model.h +wind/wind_file_cache.h +/var/hab/cusf-landing-prediction/pred_src/wind/wind_file_cache.h +altitude.h +/var/hab/cusf-landing-prediction/pred_src/altitude.h + +/var/hab/cusf-landing-prediction/pred_src/util/getdelim.c +config.h +- +getdelim.h +/var/hab/cusf-landing-prediction/pred_src/util/getdelim.h +limits.h +- +stdlib.h +- +errno.h +- + +/var/hab/cusf-landing-prediction/pred_src/util/getdelim.h +stddef.h +- +stdio.h +- +sys/types.h +- + +/var/hab/cusf-landing-prediction/pred_src/util/getline.c +config.h +- +getdelim.h +/var/hab/cusf-landing-prediction/pred_src/util/getdelim.h +getline.h +/var/hab/cusf-landing-prediction/pred_src/util/getline.h + +/var/hab/cusf-landing-prediction/pred_src/util/getline.h +stddef.h +- +stdio.h +- +sys/types.h +- + +/var/hab/cusf-landing-prediction/pred_src/util/gopt.c +stdio.h +- +stdlib.h +- +string.h +- +gopt.h +/var/hab/cusf-landing-prediction/pred_src/util/gopt.h +sysexits.h +- + +/var/hab/cusf-landing-prediction/pred_src/util/gopt.h + +/var/hab/cusf-landing-prediction/pred_src/util/random.c +random.h +/var/hab/cusf-landing-prediction/pred_src/util/random.h +glib.h +- +math.h +- + +/var/hab/cusf-landing-prediction/pred_src/util/random.h + +/var/hab/cusf-landing-prediction/pred_src/wind/../util/getline.h +stddef.h +- +stdio.h +- +sys/types.h +- + +/var/hab/cusf-landing-prediction/pred_src/wind/wind_file.c +wind_file.h +/var/hab/cusf-landing-prediction/pred_src/wind/wind_file.h +stdio.h +- +stdlib.h +- +assert.h +- +math.h +- +../util/getline.h +/var/hab/cusf-landing-prediction/pred_src/wind/../util/getline.h + +/var/hab/cusf-landing-prediction/pred_src/wind/wind_file.h + +/var/hab/cusf-landing-prediction/pred_src/wind/wind_file_cache.c +wind_file_cache.h +/var/hab/cusf-landing-prediction/pred_src/wind/wind_file_cache.h +wind_file.h +/var/hab/cusf-landing-prediction/pred_src/wind/wind_file.h +sys/types.h +- +sys/stat.h +- +stdlib.h +- +stdio.h +- +unistd.h +- +assert.h +- +dirent.h +- +errno.h +- +string.h +- +math.h +- +../util/getline.h +/var/hab/cusf-landing-prediction/pred_src/wind/../util/getline.h + +/var/hab/cusf-landing-prediction/pred_src/wind/wind_file_cache.h +wind_file.h +/var/hab/cusf-landing-prediction/pred_src/wind/wind_file.h + diff --git a/pred_src/CMakeFiles/pred.dir/DependInfo.cmake b/pred_src/CMakeFiles/pred.dir/DependInfo.cmake new file mode 100644 index 0000000..6fa5d86 --- /dev/null +++ b/pred_src/CMakeFiles/pred.dir/DependInfo.cmake @@ -0,0 +1,23 @@ +# The set of languages for which implicit dependencies are needed: +SET(CMAKE_DEPENDS_LANGUAGES + "C" + ) +# The set of files for implicit dependencies of each language: +SET(CMAKE_DEPENDS_CHECK_C + "/var/hab/cusf-landing-prediction/pred_src/altitude.c" "/var/hab/cusf-landing-prediction/pred_src/CMakeFiles/pred.dir/altitude.o" + "/var/hab/cusf-landing-prediction/pred_src/ini/dictionary.c" "/var/hab/cusf-landing-prediction/pred_src/CMakeFiles/pred.dir/ini/dictionary.o" + "/var/hab/cusf-landing-prediction/pred_src/ini/iniparser.c" "/var/hab/cusf-landing-prediction/pred_src/CMakeFiles/pred.dir/ini/iniparser.o" + "/var/hab/cusf-landing-prediction/pred_src/pred.c" "/var/hab/cusf-landing-prediction/pred_src/CMakeFiles/pred.dir/pred.o" + "/var/hab/cusf-landing-prediction/pred_src/run_model.c" "/var/hab/cusf-landing-prediction/pred_src/CMakeFiles/pred.dir/run_model.o" + "/var/hab/cusf-landing-prediction/pred_src/util/getdelim.c" "/var/hab/cusf-landing-prediction/pred_src/CMakeFiles/pred.dir/util/getdelim.o" + "/var/hab/cusf-landing-prediction/pred_src/util/getline.c" "/var/hab/cusf-landing-prediction/pred_src/CMakeFiles/pred.dir/util/getline.o" + "/var/hab/cusf-landing-prediction/pred_src/util/gopt.c" "/var/hab/cusf-landing-prediction/pred_src/CMakeFiles/pred.dir/util/gopt.o" + "/var/hab/cusf-landing-prediction/pred_src/util/random.c" "/var/hab/cusf-landing-prediction/pred_src/CMakeFiles/pred.dir/util/random.o" + "/var/hab/cusf-landing-prediction/pred_src/wind/wind_file.c" "/var/hab/cusf-landing-prediction/pred_src/CMakeFiles/pred.dir/wind/wind_file.o" + "/var/hab/cusf-landing-prediction/pred_src/wind/wind_file_cache.c" "/var/hab/cusf-landing-prediction/pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.o" + ) +SET(CMAKE_C_COMPILER_ID "GNU") + +# Targets to which this target links. +SET(CMAKE_TARGET_LINKED_INFO_FILES + ) diff --git a/pred_src/CMakeFiles/pred.dir/altitude.o b/pred_src/CMakeFiles/pred.dir/altitude.o new file mode 100644 index 0000000..c5509db Binary files /dev/null and b/pred_src/CMakeFiles/pred.dir/altitude.o differ diff --git a/pred_src/CMakeFiles/pred.dir/build.make b/pred_src/CMakeFiles/pred.dir/build.make new file mode 100644 index 0000000..c854812 --- /dev/null +++ b/pred_src/CMakeFiles/pred.dir/build.make @@ -0,0 +1,373 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.6 + +#============================================================================= +# Special targets provided by cmake. + +# Disable implicit rules so canoncical targets will work. +.SUFFIXES: + +# Remove some rules from gmake that .SUFFIXES does not remove. +SUFFIXES = + +.SUFFIXES: .hpux_make_needs_suffix_list + +# Suppress display of executed commands. +$(VERBOSE).SILENT: + +# A target that is always out of date. +cmake_force: +.PHONY : cmake_force + +#============================================================================= +# Set environment variables for the build. + +# The shell in which to execute make rules. +SHELL = /bin/sh + +# The CMake executable. +CMAKE_COMMAND = /usr/bin/cmake + +# The command to remove a file. +RM = /usr/bin/cmake -E remove -f + +# The program to use to edit the cache. +CMAKE_EDIT_COMMAND = /usr/bin/ccmake + +# The top-level source directory on which CMake was run. +CMAKE_SOURCE_DIR = /var/hab/cusf-landing-prediction + +# The top-level build directory on which CMake was run. +CMAKE_BINARY_DIR = /var/hab/cusf-landing-prediction + +# Include any dependencies generated for this target. +include pred_src/CMakeFiles/pred.dir/depend.make + +# Include the progress variables for this target. +include pred_src/CMakeFiles/pred.dir/progress.make + +# Include the compile flags for this target's objects. +include pred_src/CMakeFiles/pred.dir/flags.make + +pred_src/CMakeFiles/pred.dir/util/gopt.o: pred_src/CMakeFiles/pred.dir/flags.make +pred_src/CMakeFiles/pred.dir/util/gopt.o: pred_src/util/gopt.c + $(CMAKE_COMMAND) -E cmake_progress_report /var/hab/cusf-landing-prediction/CMakeFiles $(CMAKE_PROGRESS_1) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object pred_src/CMakeFiles/pred.dir/util/gopt.o" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/pred.dir/util/gopt.o -c /var/hab/cusf-landing-prediction/pred_src/util/gopt.c + +pred_src/CMakeFiles/pred.dir/util/gopt.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/pred.dir/util/gopt.i" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /var/hab/cusf-landing-prediction/pred_src/util/gopt.c > CMakeFiles/pred.dir/util/gopt.i + +pred_src/CMakeFiles/pred.dir/util/gopt.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/pred.dir/util/gopt.s" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /var/hab/cusf-landing-prediction/pred_src/util/gopt.c -o CMakeFiles/pred.dir/util/gopt.s + +pred_src/CMakeFiles/pred.dir/util/gopt.o.requires: +.PHONY : pred_src/CMakeFiles/pred.dir/util/gopt.o.requires + +pred_src/CMakeFiles/pred.dir/util/gopt.o.provides: pred_src/CMakeFiles/pred.dir/util/gopt.o.requires + $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/util/gopt.o.provides.build +.PHONY : pred_src/CMakeFiles/pred.dir/util/gopt.o.provides + +pred_src/CMakeFiles/pred.dir/util/gopt.o.provides.build: pred_src/CMakeFiles/pred.dir/util/gopt.o +.PHONY : pred_src/CMakeFiles/pred.dir/util/gopt.o.provides.build + +pred_src/CMakeFiles/pred.dir/util/getdelim.o: pred_src/CMakeFiles/pred.dir/flags.make +pred_src/CMakeFiles/pred.dir/util/getdelim.o: pred_src/util/getdelim.c + $(CMAKE_COMMAND) -E cmake_progress_report /var/hab/cusf-landing-prediction/CMakeFiles $(CMAKE_PROGRESS_2) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object pred_src/CMakeFiles/pred.dir/util/getdelim.o" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/pred.dir/util/getdelim.o -c /var/hab/cusf-landing-prediction/pred_src/util/getdelim.c + +pred_src/CMakeFiles/pred.dir/util/getdelim.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/pred.dir/util/getdelim.i" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /var/hab/cusf-landing-prediction/pred_src/util/getdelim.c > CMakeFiles/pred.dir/util/getdelim.i + +pred_src/CMakeFiles/pred.dir/util/getdelim.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/pred.dir/util/getdelim.s" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /var/hab/cusf-landing-prediction/pred_src/util/getdelim.c -o CMakeFiles/pred.dir/util/getdelim.s + +pred_src/CMakeFiles/pred.dir/util/getdelim.o.requires: +.PHONY : pred_src/CMakeFiles/pred.dir/util/getdelim.o.requires + +pred_src/CMakeFiles/pred.dir/util/getdelim.o.provides: pred_src/CMakeFiles/pred.dir/util/getdelim.o.requires + $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/util/getdelim.o.provides.build +.PHONY : pred_src/CMakeFiles/pred.dir/util/getdelim.o.provides + +pred_src/CMakeFiles/pred.dir/util/getdelim.o.provides.build: pred_src/CMakeFiles/pred.dir/util/getdelim.o +.PHONY : pred_src/CMakeFiles/pred.dir/util/getdelim.o.provides.build + +pred_src/CMakeFiles/pred.dir/util/getline.o: pred_src/CMakeFiles/pred.dir/flags.make +pred_src/CMakeFiles/pred.dir/util/getline.o: pred_src/util/getline.c + $(CMAKE_COMMAND) -E cmake_progress_report /var/hab/cusf-landing-prediction/CMakeFiles $(CMAKE_PROGRESS_3) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object pred_src/CMakeFiles/pred.dir/util/getline.o" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/pred.dir/util/getline.o -c /var/hab/cusf-landing-prediction/pred_src/util/getline.c + +pred_src/CMakeFiles/pred.dir/util/getline.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/pred.dir/util/getline.i" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /var/hab/cusf-landing-prediction/pred_src/util/getline.c > CMakeFiles/pred.dir/util/getline.i + +pred_src/CMakeFiles/pred.dir/util/getline.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/pred.dir/util/getline.s" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /var/hab/cusf-landing-prediction/pred_src/util/getline.c -o CMakeFiles/pred.dir/util/getline.s + +pred_src/CMakeFiles/pred.dir/util/getline.o.requires: +.PHONY : pred_src/CMakeFiles/pred.dir/util/getline.o.requires + +pred_src/CMakeFiles/pred.dir/util/getline.o.provides: pred_src/CMakeFiles/pred.dir/util/getline.o.requires + $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/util/getline.o.provides.build +.PHONY : pred_src/CMakeFiles/pred.dir/util/getline.o.provides + +pred_src/CMakeFiles/pred.dir/util/getline.o.provides.build: pred_src/CMakeFiles/pred.dir/util/getline.o +.PHONY : pred_src/CMakeFiles/pred.dir/util/getline.o.provides.build + +pred_src/CMakeFiles/pred.dir/util/random.o: pred_src/CMakeFiles/pred.dir/flags.make +pred_src/CMakeFiles/pred.dir/util/random.o: pred_src/util/random.c + $(CMAKE_COMMAND) -E cmake_progress_report /var/hab/cusf-landing-prediction/CMakeFiles $(CMAKE_PROGRESS_4) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object pred_src/CMakeFiles/pred.dir/util/random.o" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/pred.dir/util/random.o -c /var/hab/cusf-landing-prediction/pred_src/util/random.c + +pred_src/CMakeFiles/pred.dir/util/random.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/pred.dir/util/random.i" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /var/hab/cusf-landing-prediction/pred_src/util/random.c > CMakeFiles/pred.dir/util/random.i + +pred_src/CMakeFiles/pred.dir/util/random.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/pred.dir/util/random.s" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /var/hab/cusf-landing-prediction/pred_src/util/random.c -o CMakeFiles/pred.dir/util/random.s + +pred_src/CMakeFiles/pred.dir/util/random.o.requires: +.PHONY : pred_src/CMakeFiles/pred.dir/util/random.o.requires + +pred_src/CMakeFiles/pred.dir/util/random.o.provides: pred_src/CMakeFiles/pred.dir/util/random.o.requires + $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/util/random.o.provides.build +.PHONY : pred_src/CMakeFiles/pred.dir/util/random.o.provides + +pred_src/CMakeFiles/pred.dir/util/random.o.provides.build: pred_src/CMakeFiles/pred.dir/util/random.o +.PHONY : pred_src/CMakeFiles/pred.dir/util/random.o.provides.build + +pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.o: pred_src/CMakeFiles/pred.dir/flags.make +pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.o: pred_src/wind/wind_file_cache.c + $(CMAKE_COMMAND) -E cmake_progress_report /var/hab/cusf-landing-prediction/CMakeFiles $(CMAKE_PROGRESS_5) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.o" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/pred.dir/wind/wind_file_cache.o -c /var/hab/cusf-landing-prediction/pred_src/wind/wind_file_cache.c + +pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/pred.dir/wind/wind_file_cache.i" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /var/hab/cusf-landing-prediction/pred_src/wind/wind_file_cache.c > CMakeFiles/pred.dir/wind/wind_file_cache.i + +pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/pred.dir/wind/wind_file_cache.s" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /var/hab/cusf-landing-prediction/pred_src/wind/wind_file_cache.c -o CMakeFiles/pred.dir/wind/wind_file_cache.s + +pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.o.requires: +.PHONY : pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.o.requires + +pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.o.provides: pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.o.requires + $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.o.provides.build +.PHONY : pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.o.provides + +pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.o.provides.build: pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.o +.PHONY : pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.o.provides.build + +pred_src/CMakeFiles/pred.dir/wind/wind_file.o: pred_src/CMakeFiles/pred.dir/flags.make +pred_src/CMakeFiles/pred.dir/wind/wind_file.o: pred_src/wind/wind_file.c + $(CMAKE_COMMAND) -E cmake_progress_report /var/hab/cusf-landing-prediction/CMakeFiles $(CMAKE_PROGRESS_6) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object pred_src/CMakeFiles/pred.dir/wind/wind_file.o" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/pred.dir/wind/wind_file.o -c /var/hab/cusf-landing-prediction/pred_src/wind/wind_file.c + +pred_src/CMakeFiles/pred.dir/wind/wind_file.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/pred.dir/wind/wind_file.i" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /var/hab/cusf-landing-prediction/pred_src/wind/wind_file.c > CMakeFiles/pred.dir/wind/wind_file.i + +pred_src/CMakeFiles/pred.dir/wind/wind_file.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/pred.dir/wind/wind_file.s" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /var/hab/cusf-landing-prediction/pred_src/wind/wind_file.c -o CMakeFiles/pred.dir/wind/wind_file.s + +pred_src/CMakeFiles/pred.dir/wind/wind_file.o.requires: +.PHONY : pred_src/CMakeFiles/pred.dir/wind/wind_file.o.requires + +pred_src/CMakeFiles/pred.dir/wind/wind_file.o.provides: pred_src/CMakeFiles/pred.dir/wind/wind_file.o.requires + $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/wind/wind_file.o.provides.build +.PHONY : pred_src/CMakeFiles/pred.dir/wind/wind_file.o.provides + +pred_src/CMakeFiles/pred.dir/wind/wind_file.o.provides.build: pred_src/CMakeFiles/pred.dir/wind/wind_file.o +.PHONY : pred_src/CMakeFiles/pred.dir/wind/wind_file.o.provides.build + +pred_src/CMakeFiles/pred.dir/altitude.o: pred_src/CMakeFiles/pred.dir/flags.make +pred_src/CMakeFiles/pred.dir/altitude.o: pred_src/altitude.c + $(CMAKE_COMMAND) -E cmake_progress_report /var/hab/cusf-landing-prediction/CMakeFiles $(CMAKE_PROGRESS_7) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object pred_src/CMakeFiles/pred.dir/altitude.o" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/pred.dir/altitude.o -c /var/hab/cusf-landing-prediction/pred_src/altitude.c + +pred_src/CMakeFiles/pred.dir/altitude.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/pred.dir/altitude.i" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /var/hab/cusf-landing-prediction/pred_src/altitude.c > CMakeFiles/pred.dir/altitude.i + +pred_src/CMakeFiles/pred.dir/altitude.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/pred.dir/altitude.s" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /var/hab/cusf-landing-prediction/pred_src/altitude.c -o CMakeFiles/pred.dir/altitude.s + +pred_src/CMakeFiles/pred.dir/altitude.o.requires: +.PHONY : pred_src/CMakeFiles/pred.dir/altitude.o.requires + +pred_src/CMakeFiles/pred.dir/altitude.o.provides: pred_src/CMakeFiles/pred.dir/altitude.o.requires + $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/altitude.o.provides.build +.PHONY : pred_src/CMakeFiles/pred.dir/altitude.o.provides + +pred_src/CMakeFiles/pred.dir/altitude.o.provides.build: pred_src/CMakeFiles/pred.dir/altitude.o +.PHONY : pred_src/CMakeFiles/pred.dir/altitude.o.provides.build + +pred_src/CMakeFiles/pred.dir/pred.o: pred_src/CMakeFiles/pred.dir/flags.make +pred_src/CMakeFiles/pred.dir/pred.o: pred_src/pred.c + $(CMAKE_COMMAND) -E cmake_progress_report /var/hab/cusf-landing-prediction/CMakeFiles $(CMAKE_PROGRESS_8) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object pred_src/CMakeFiles/pred.dir/pred.o" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/pred.dir/pred.o -c /var/hab/cusf-landing-prediction/pred_src/pred.c + +pred_src/CMakeFiles/pred.dir/pred.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/pred.dir/pred.i" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /var/hab/cusf-landing-prediction/pred_src/pred.c > CMakeFiles/pred.dir/pred.i + +pred_src/CMakeFiles/pred.dir/pred.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/pred.dir/pred.s" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /var/hab/cusf-landing-prediction/pred_src/pred.c -o CMakeFiles/pred.dir/pred.s + +pred_src/CMakeFiles/pred.dir/pred.o.requires: +.PHONY : pred_src/CMakeFiles/pred.dir/pred.o.requires + +pred_src/CMakeFiles/pred.dir/pred.o.provides: pred_src/CMakeFiles/pred.dir/pred.o.requires + $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/pred.o.provides.build +.PHONY : pred_src/CMakeFiles/pred.dir/pred.o.provides + +pred_src/CMakeFiles/pred.dir/pred.o.provides.build: pred_src/CMakeFiles/pred.dir/pred.o +.PHONY : pred_src/CMakeFiles/pred.dir/pred.o.provides.build + +pred_src/CMakeFiles/pred.dir/run_model.o: pred_src/CMakeFiles/pred.dir/flags.make +pred_src/CMakeFiles/pred.dir/run_model.o: pred_src/run_model.c + $(CMAKE_COMMAND) -E cmake_progress_report /var/hab/cusf-landing-prediction/CMakeFiles $(CMAKE_PROGRESS_9) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object pred_src/CMakeFiles/pred.dir/run_model.o" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/pred.dir/run_model.o -c /var/hab/cusf-landing-prediction/pred_src/run_model.c + +pred_src/CMakeFiles/pred.dir/run_model.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/pred.dir/run_model.i" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /var/hab/cusf-landing-prediction/pred_src/run_model.c > CMakeFiles/pred.dir/run_model.i + +pred_src/CMakeFiles/pred.dir/run_model.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/pred.dir/run_model.s" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /var/hab/cusf-landing-prediction/pred_src/run_model.c -o CMakeFiles/pred.dir/run_model.s + +pred_src/CMakeFiles/pred.dir/run_model.o.requires: +.PHONY : pred_src/CMakeFiles/pred.dir/run_model.o.requires + +pred_src/CMakeFiles/pred.dir/run_model.o.provides: pred_src/CMakeFiles/pred.dir/run_model.o.requires + $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/run_model.o.provides.build +.PHONY : pred_src/CMakeFiles/pred.dir/run_model.o.provides + +pred_src/CMakeFiles/pred.dir/run_model.o.provides.build: pred_src/CMakeFiles/pred.dir/run_model.o +.PHONY : pred_src/CMakeFiles/pred.dir/run_model.o.provides.build + +pred_src/CMakeFiles/pred.dir/ini/iniparser.o: pred_src/CMakeFiles/pred.dir/flags.make +pred_src/CMakeFiles/pred.dir/ini/iniparser.o: pred_src/ini/iniparser.c + $(CMAKE_COMMAND) -E cmake_progress_report /var/hab/cusf-landing-prediction/CMakeFiles $(CMAKE_PROGRESS_10) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object pred_src/CMakeFiles/pred.dir/ini/iniparser.o" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/pred.dir/ini/iniparser.o -c /var/hab/cusf-landing-prediction/pred_src/ini/iniparser.c + +pred_src/CMakeFiles/pred.dir/ini/iniparser.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/pred.dir/ini/iniparser.i" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /var/hab/cusf-landing-prediction/pred_src/ini/iniparser.c > CMakeFiles/pred.dir/ini/iniparser.i + +pred_src/CMakeFiles/pred.dir/ini/iniparser.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/pred.dir/ini/iniparser.s" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /var/hab/cusf-landing-prediction/pred_src/ini/iniparser.c -o CMakeFiles/pred.dir/ini/iniparser.s + +pred_src/CMakeFiles/pred.dir/ini/iniparser.o.requires: +.PHONY : pred_src/CMakeFiles/pred.dir/ini/iniparser.o.requires + +pred_src/CMakeFiles/pred.dir/ini/iniparser.o.provides: pred_src/CMakeFiles/pred.dir/ini/iniparser.o.requires + $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/ini/iniparser.o.provides.build +.PHONY : pred_src/CMakeFiles/pred.dir/ini/iniparser.o.provides + +pred_src/CMakeFiles/pred.dir/ini/iniparser.o.provides.build: pred_src/CMakeFiles/pred.dir/ini/iniparser.o +.PHONY : pred_src/CMakeFiles/pred.dir/ini/iniparser.o.provides.build + +pred_src/CMakeFiles/pred.dir/ini/dictionary.o: pred_src/CMakeFiles/pred.dir/flags.make +pred_src/CMakeFiles/pred.dir/ini/dictionary.o: pred_src/ini/dictionary.c + $(CMAKE_COMMAND) -E cmake_progress_report /var/hab/cusf-landing-prediction/CMakeFiles $(CMAKE_PROGRESS_11) + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building C object pred_src/CMakeFiles/pred.dir/ini/dictionary.o" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -o CMakeFiles/pred.dir/ini/dictionary.o -c /var/hab/cusf-landing-prediction/pred_src/ini/dictionary.c + +pred_src/CMakeFiles/pred.dir/ini/dictionary.i: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing C source to CMakeFiles/pred.dir/ini/dictionary.i" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -E /var/hab/cusf-landing-prediction/pred_src/ini/dictionary.c > CMakeFiles/pred.dir/ini/dictionary.i + +pred_src/CMakeFiles/pred.dir/ini/dictionary.s: cmake_force + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling C source to assembly CMakeFiles/pred.dir/ini/dictionary.s" + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/gcc $(C_DEFINES) $(C_FLAGS) -S /var/hab/cusf-landing-prediction/pred_src/ini/dictionary.c -o CMakeFiles/pred.dir/ini/dictionary.s + +pred_src/CMakeFiles/pred.dir/ini/dictionary.o.requires: +.PHONY : pred_src/CMakeFiles/pred.dir/ini/dictionary.o.requires + +pred_src/CMakeFiles/pred.dir/ini/dictionary.o.provides: pred_src/CMakeFiles/pred.dir/ini/dictionary.o.requires + $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/ini/dictionary.o.provides.build +.PHONY : pred_src/CMakeFiles/pred.dir/ini/dictionary.o.provides + +pred_src/CMakeFiles/pred.dir/ini/dictionary.o.provides.build: pred_src/CMakeFiles/pred.dir/ini/dictionary.o +.PHONY : pred_src/CMakeFiles/pred.dir/ini/dictionary.o.provides.build + +# Object files for target pred +pred_OBJECTS = \ +"CMakeFiles/pred.dir/util/gopt.o" \ +"CMakeFiles/pred.dir/util/getdelim.o" \ +"CMakeFiles/pred.dir/util/getline.o" \ +"CMakeFiles/pred.dir/util/random.o" \ +"CMakeFiles/pred.dir/wind/wind_file_cache.o" \ +"CMakeFiles/pred.dir/wind/wind_file.o" \ +"CMakeFiles/pred.dir/altitude.o" \ +"CMakeFiles/pred.dir/pred.o" \ +"CMakeFiles/pred.dir/run_model.o" \ +"CMakeFiles/pred.dir/ini/iniparser.o" \ +"CMakeFiles/pred.dir/ini/dictionary.o" + +# External object files for target pred +pred_EXTERNAL_OBJECTS = + +pred_src/pred: pred_src/CMakeFiles/pred.dir/util/gopt.o +pred_src/pred: pred_src/CMakeFiles/pred.dir/util/getdelim.o +pred_src/pred: pred_src/CMakeFiles/pred.dir/util/getline.o +pred_src/pred: pred_src/CMakeFiles/pred.dir/util/random.o +pred_src/pred: pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.o +pred_src/pred: pred_src/CMakeFiles/pred.dir/wind/wind_file.o +pred_src/pred: pred_src/CMakeFiles/pred.dir/altitude.o +pred_src/pred: pred_src/CMakeFiles/pred.dir/pred.o +pred_src/pred: pred_src/CMakeFiles/pred.dir/run_model.o +pred_src/pred: pred_src/CMakeFiles/pred.dir/ini/iniparser.o +pred_src/pred: pred_src/CMakeFiles/pred.dir/ini/dictionary.o +pred_src/pred: pred_src/CMakeFiles/pred.dir/build.make +pred_src/pred: pred_src/CMakeFiles/pred.dir/link.txt + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --red --bold "Linking C executable pred" + cd /var/hab/cusf-landing-prediction/pred_src && $(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/pred.dir/link.txt --verbose=$(VERBOSE) + +# Rule to build all files generated by this target. +pred_src/CMakeFiles/pred.dir/build: pred_src/pred +.PHONY : pred_src/CMakeFiles/pred.dir/build + +pred_src/CMakeFiles/pred.dir/requires: pred_src/CMakeFiles/pred.dir/util/gopt.o.requires +pred_src/CMakeFiles/pred.dir/requires: pred_src/CMakeFiles/pred.dir/util/getdelim.o.requires +pred_src/CMakeFiles/pred.dir/requires: pred_src/CMakeFiles/pred.dir/util/getline.o.requires +pred_src/CMakeFiles/pred.dir/requires: pred_src/CMakeFiles/pred.dir/util/random.o.requires +pred_src/CMakeFiles/pred.dir/requires: pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.o.requires +pred_src/CMakeFiles/pred.dir/requires: pred_src/CMakeFiles/pred.dir/wind/wind_file.o.requires +pred_src/CMakeFiles/pred.dir/requires: pred_src/CMakeFiles/pred.dir/altitude.o.requires +pred_src/CMakeFiles/pred.dir/requires: pred_src/CMakeFiles/pred.dir/pred.o.requires +pred_src/CMakeFiles/pred.dir/requires: pred_src/CMakeFiles/pred.dir/run_model.o.requires +pred_src/CMakeFiles/pred.dir/requires: pred_src/CMakeFiles/pred.dir/ini/iniparser.o.requires +pred_src/CMakeFiles/pred.dir/requires: pred_src/CMakeFiles/pred.dir/ini/dictionary.o.requires +.PHONY : pred_src/CMakeFiles/pred.dir/requires + +pred_src/CMakeFiles/pred.dir/clean: + cd /var/hab/cusf-landing-prediction/pred_src && $(CMAKE_COMMAND) -P CMakeFiles/pred.dir/cmake_clean.cmake +.PHONY : pred_src/CMakeFiles/pred.dir/clean + +pred_src/CMakeFiles/pred.dir/depend: + cd /var/hab/cusf-landing-prediction && $(CMAKE_COMMAND) -E cmake_depends "Unix Makefiles" /var/hab/cusf-landing-prediction /var/hab/cusf-landing-prediction/pred_src /var/hab/cusf-landing-prediction /var/hab/cusf-landing-prediction/pred_src /var/hab/cusf-landing-prediction/pred_src/CMakeFiles/pred.dir/DependInfo.cmake --color=$(COLOR) +.PHONY : pred_src/CMakeFiles/pred.dir/depend + diff --git a/pred_src/CMakeFiles/pred.dir/cmake_clean.cmake b/pred_src/CMakeFiles/pred.dir/cmake_clean.cmake new file mode 100644 index 0000000..328f668 --- /dev/null +++ b/pred_src/CMakeFiles/pred.dir/cmake_clean.cmake @@ -0,0 +1,20 @@ +FILE(REMOVE_RECURSE +"CMakeFiles/pred.dir/util/gopt.o" +"CMakeFiles/pred.dir/util/getdelim.o" +"CMakeFiles/pred.dir/util/getline.o" +"CMakeFiles/pred.dir/util/random.o" +"CMakeFiles/pred.dir/wind/wind_file_cache.o" +"CMakeFiles/pred.dir/wind/wind_file.o" +"CMakeFiles/pred.dir/altitude.o" +"CMakeFiles/pred.dir/pred.o" +"CMakeFiles/pred.dir/run_model.o" +"CMakeFiles/pred.dir/ini/iniparser.o" +"CMakeFiles/pred.dir/ini/dictionary.o" +"pred.pdb" +"pred" +) + +# Per-language clean rules from dependency scanning. +FOREACH(lang C) + INCLUDE(CMakeFiles/pred.dir/cmake_clean_${lang}.cmake OPTIONAL) +ENDFOREACH(lang) diff --git a/pred_src/CMakeFiles/pred.dir/depend.internal b/pred_src/CMakeFiles/pred.dir/depend.internal new file mode 100644 index 0000000..39afdaa --- /dev/null +++ b/pred_src/CMakeFiles/pred.dir/depend.internal @@ -0,0 +1,114 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.6 + +pred_src/CMakeFiles/pred.dir/altitude.o + /var/hab/cusf-landing-prediction/pred_src/altitude.c + /var/hab/cusf-landing-prediction/pred_src/altitude.h + /var/hab/cusf-landing-prediction/pred_src/pred.h + /var/hab/cusf-landing-prediction/pred_src/run_model.h + /var/hab/cusf-landing-prediction/pred_src/wind/wind_file.h + /var/hab/cusf-landing-prediction/pred_src/wind/wind_file_cache.h +pred_src/CMakeFiles/pred.dir/ini/dictionary.o + /var/hab/cusf-landing-prediction/pred_src/ini/dictionary.c + /var/hab/cusf-landing-prediction/pred_src/ini/dictionary.h +pred_src/CMakeFiles/pred.dir/ini/iniparser.o + /var/hab/cusf-landing-prediction/pred_src/ini/dictionary.h + /var/hab/cusf-landing-prediction/pred_src/ini/iniparser.c + /var/hab/cusf-landing-prediction/pred_src/ini/iniparser.h +pred_src/CMakeFiles/pred.dir/pred.o + /var/hab/cusf-landing-prediction/pred_src/altitude.h + /var/hab/cusf-landing-prediction/pred_src/ini/dictionary.h + /var/hab/cusf-landing-prediction/pred_src/ini/iniparser.h + /var/hab/cusf-landing-prediction/pred_src/pred.c + /var/hab/cusf-landing-prediction/pred_src/pred.h + /var/hab/cusf-landing-prediction/pred_src/run_model.h + /var/hab/cusf-landing-prediction/pred_src/util/gopt.h + /var/hab/cusf-landing-prediction/pred_src/wind/wind_file.h + /var/hab/cusf-landing-prediction/pred_src/wind/wind_file_cache.h +pred_src/CMakeFiles/pred.dir/run_model.o + /var/hab/cusf-landing-prediction/pred_src/altitude.h + /var/hab/cusf-landing-prediction/pred_src/pred.h + /var/hab/cusf-landing-prediction/pred_src/run_model.c + /var/hab/cusf-landing-prediction/pred_src/run_model.h + /var/hab/cusf-landing-prediction/pred_src/util/random.h + /var/hab/cusf-landing-prediction/pred_src/wind/wind_file.h + /var/hab/cusf-landing-prediction/pred_src/wind/wind_file_cache.h +pred_src/CMakeFiles/pred.dir/util/getdelim.o + /var/hab/cusf-landing-prediction/pred_src/util/getdelim.c + /var/hab/cusf-landing-prediction/pred_src/util/getdelim.h +pred_src/CMakeFiles/pred.dir/util/getline.o + /var/hab/cusf-landing-prediction/pred_src/util/getdelim.h + /var/hab/cusf-landing-prediction/pred_src/util/getline.c + /var/hab/cusf-landing-prediction/pred_src/util/getline.h +pred_src/CMakeFiles/pred.dir/util/gopt.o + /var/hab/cusf-landing-prediction/pred_src/util/gopt.c + /var/hab/cusf-landing-prediction/pred_src/util/gopt.h +pred_src/CMakeFiles/pred.dir/util/random.o + /usr/include/glib-2.0/glib.h + /usr/include/glib-2.0/glib/galloca.h + /usr/include/glib-2.0/glib/garray.h + /usr/include/glib-2.0/glib/gasyncqueue.h + /usr/include/glib-2.0/glib/gatomic.h + /usr/include/glib-2.0/glib/gbacktrace.h + /usr/include/glib-2.0/glib/gbase64.h + /usr/include/glib-2.0/glib/gbookmarkfile.h + /usr/include/glib-2.0/glib/gcache.h + /usr/include/glib-2.0/glib/gchecksum.h + /usr/include/glib-2.0/glib/gcompletion.h + /usr/include/glib-2.0/glib/gconvert.h + /usr/include/glib-2.0/glib/gdataset.h + /usr/include/glib-2.0/glib/gdate.h + /usr/include/glib-2.0/glib/gdir.h + /usr/include/glib-2.0/glib/gerror.h + /usr/include/glib-2.0/glib/gfileutils.h + /usr/include/glib-2.0/glib/ghash.h + /usr/include/glib-2.0/glib/ghook.h + /usr/include/glib-2.0/glib/giochannel.h + /usr/include/glib-2.0/glib/gkeyfile.h + /usr/include/glib-2.0/glib/glist.h + /usr/include/glib-2.0/glib/gmacros.h + /usr/include/glib-2.0/glib/gmain.h + /usr/include/glib-2.0/glib/gmappedfile.h + /usr/include/glib-2.0/glib/gmarkup.h + /usr/include/glib-2.0/glib/gmem.h + /usr/include/glib-2.0/glib/gmessages.h + /usr/include/glib-2.0/glib/gnode.h + /usr/include/glib-2.0/glib/goption.h + /usr/include/glib-2.0/glib/gpattern.h + /usr/include/glib-2.0/glib/gprimes.h + /usr/include/glib-2.0/glib/gqsort.h + /usr/include/glib-2.0/glib/gquark.h + /usr/include/glib-2.0/glib/gqueue.h + /usr/include/glib-2.0/glib/grand.h + /usr/include/glib-2.0/glib/gregex.h + /usr/include/glib-2.0/glib/grel.h + /usr/include/glib-2.0/glib/gscanner.h + /usr/include/glib-2.0/glib/gsequence.h + /usr/include/glib-2.0/glib/gshell.h + /usr/include/glib-2.0/glib/gslice.h + /usr/include/glib-2.0/glib/gslist.h + /usr/include/glib-2.0/glib/gspawn.h + /usr/include/glib-2.0/glib/gstrfuncs.h + /usr/include/glib-2.0/glib/gstring.h + /usr/include/glib-2.0/glib/gtestutils.h + /usr/include/glib-2.0/glib/gthread.h + /usr/include/glib-2.0/glib/gthreadpool.h + /usr/include/glib-2.0/glib/gtimer.h + /usr/include/glib-2.0/glib/gtree.h + /usr/include/glib-2.0/glib/gtypes.h + /usr/include/glib-2.0/glib/gunicode.h + /usr/include/glib-2.0/glib/gurifuncs.h + /usr/include/glib-2.0/glib/gutils.h + /usr/include/glib-2.0/glib/gwin32.h + /usr/lib/glib-2.0/include/glibconfig.h + /var/hab/cusf-landing-prediction/pred_src/util/random.c + /var/hab/cusf-landing-prediction/pred_src/util/random.h +pred_src/CMakeFiles/pred.dir/wind/wind_file.o + /var/hab/cusf-landing-prediction/pred_src/wind/../util/getline.h + /var/hab/cusf-landing-prediction/pred_src/wind/wind_file.c + /var/hab/cusf-landing-prediction/pred_src/wind/wind_file.h +pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.o + /var/hab/cusf-landing-prediction/pred_src/wind/../util/getline.h + /var/hab/cusf-landing-prediction/pred_src/wind/wind_file.h + /var/hab/cusf-landing-prediction/pred_src/wind/wind_file_cache.c + /var/hab/cusf-landing-prediction/pred_src/wind/wind_file_cache.h diff --git a/pred_src/CMakeFiles/pred.dir/depend.make b/pred_src/CMakeFiles/pred.dir/depend.make new file mode 100644 index 0000000..a972635 --- /dev/null +++ b/pred_src/CMakeFiles/pred.dir/depend.make @@ -0,0 +1,114 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.6 + +pred_src/CMakeFiles/pred.dir/altitude.o: pred_src/altitude.c +pred_src/CMakeFiles/pred.dir/altitude.o: pred_src/altitude.h +pred_src/CMakeFiles/pred.dir/altitude.o: pred_src/pred.h +pred_src/CMakeFiles/pred.dir/altitude.o: pred_src/run_model.h +pred_src/CMakeFiles/pred.dir/altitude.o: pred_src/wind/wind_file.h +pred_src/CMakeFiles/pred.dir/altitude.o: pred_src/wind/wind_file_cache.h + +pred_src/CMakeFiles/pred.dir/ini/dictionary.o: pred_src/ini/dictionary.c +pred_src/CMakeFiles/pred.dir/ini/dictionary.o: pred_src/ini/dictionary.h + +pred_src/CMakeFiles/pred.dir/ini/iniparser.o: pred_src/ini/dictionary.h +pred_src/CMakeFiles/pred.dir/ini/iniparser.o: pred_src/ini/iniparser.c +pred_src/CMakeFiles/pred.dir/ini/iniparser.o: pred_src/ini/iniparser.h + +pred_src/CMakeFiles/pred.dir/pred.o: pred_src/altitude.h +pred_src/CMakeFiles/pred.dir/pred.o: pred_src/ini/dictionary.h +pred_src/CMakeFiles/pred.dir/pred.o: pred_src/ini/iniparser.h +pred_src/CMakeFiles/pred.dir/pred.o: pred_src/pred.c +pred_src/CMakeFiles/pred.dir/pred.o: pred_src/pred.h +pred_src/CMakeFiles/pred.dir/pred.o: pred_src/run_model.h +pred_src/CMakeFiles/pred.dir/pred.o: pred_src/util/gopt.h +pred_src/CMakeFiles/pred.dir/pred.o: pred_src/wind/wind_file.h +pred_src/CMakeFiles/pred.dir/pred.o: pred_src/wind/wind_file_cache.h + +pred_src/CMakeFiles/pred.dir/run_model.o: pred_src/altitude.h +pred_src/CMakeFiles/pred.dir/run_model.o: pred_src/pred.h +pred_src/CMakeFiles/pred.dir/run_model.o: pred_src/run_model.c +pred_src/CMakeFiles/pred.dir/run_model.o: pred_src/run_model.h +pred_src/CMakeFiles/pred.dir/run_model.o: pred_src/util/random.h +pred_src/CMakeFiles/pred.dir/run_model.o: pred_src/wind/wind_file.h +pred_src/CMakeFiles/pred.dir/run_model.o: pred_src/wind/wind_file_cache.h + +pred_src/CMakeFiles/pred.dir/util/getdelim.o: pred_src/util/getdelim.c +pred_src/CMakeFiles/pred.dir/util/getdelim.o: pred_src/util/getdelim.h + +pred_src/CMakeFiles/pred.dir/util/getline.o: pred_src/util/getdelim.h +pred_src/CMakeFiles/pred.dir/util/getline.o: pred_src/util/getline.c +pred_src/CMakeFiles/pred.dir/util/getline.o: pred_src/util/getline.h + +pred_src/CMakeFiles/pred.dir/util/gopt.o: pred_src/util/gopt.c +pred_src/CMakeFiles/pred.dir/util/gopt.o: pred_src/util/gopt.h + +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/galloca.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/garray.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gasyncqueue.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gatomic.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gbacktrace.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gbase64.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gbookmarkfile.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gcache.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gchecksum.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gcompletion.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gconvert.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gdataset.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gdate.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gdir.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gerror.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gfileutils.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/ghash.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/ghook.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/giochannel.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gkeyfile.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/glist.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gmacros.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gmain.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gmappedfile.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gmarkup.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gmem.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gmessages.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gnode.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/goption.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gpattern.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gprimes.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gqsort.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gquark.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gqueue.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/grand.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gregex.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/grel.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gscanner.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gsequence.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gshell.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gslice.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gslist.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gspawn.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gstrfuncs.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gstring.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gtestutils.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gthread.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gthreadpool.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gtimer.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gtree.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gtypes.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gunicode.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gurifuncs.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gutils.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/include/glib-2.0/glib/gwin32.h +pred_src/CMakeFiles/pred.dir/util/random.o: /usr/lib/glib-2.0/include/glibconfig.h +pred_src/CMakeFiles/pred.dir/util/random.o: pred_src/util/random.c +pred_src/CMakeFiles/pred.dir/util/random.o: pred_src/util/random.h + +pred_src/CMakeFiles/pred.dir/wind/wind_file.o: pred_src/wind/../util/getline.h +pred_src/CMakeFiles/pred.dir/wind/wind_file.o: pred_src/wind/wind_file.c +pred_src/CMakeFiles/pred.dir/wind/wind_file.o: pred_src/wind/wind_file.h + +pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.o: pred_src/wind/../util/getline.h +pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.o: pred_src/wind/wind_file.h +pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.o: pred_src/wind/wind_file_cache.c +pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.o: pred_src/wind/wind_file_cache.h + diff --git a/pred_src/CMakeFiles/pred.dir/flags.make b/pred_src/CMakeFiles/pred.dir/flags.make new file mode 100644 index 0000000..f3b49fd --- /dev/null +++ b/pred_src/CMakeFiles/pred.dir/flags.make @@ -0,0 +1,8 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.6 + +# compile C with /usr/bin/gcc +C_FLAGS = -O9 -Wall -Werror -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include + +C_DEFINES = + diff --git a/pred_src/CMakeFiles/pred.dir/ini/dictionary.o b/pred_src/CMakeFiles/pred.dir/ini/dictionary.o new file mode 100644 index 0000000..d80fa52 Binary files /dev/null and b/pred_src/CMakeFiles/pred.dir/ini/dictionary.o differ diff --git a/pred_src/CMakeFiles/pred.dir/ini/iniparser.o b/pred_src/CMakeFiles/pred.dir/ini/iniparser.o new file mode 100644 index 0000000..a5021b9 Binary files /dev/null and b/pred_src/CMakeFiles/pred.dir/ini/iniparser.o differ diff --git a/pred_src/CMakeFiles/pred.dir/link.txt b/pred_src/CMakeFiles/pred.dir/link.txt new file mode 100644 index 0000000..3336759 --- /dev/null +++ b/pred_src/CMakeFiles/pred.dir/link.txt @@ -0,0 +1 @@ +/usr/bin/gcc -O9 -Wall -Werror CMakeFiles/pred.dir/util/gopt.o CMakeFiles/pred.dir/util/getdelim.o CMakeFiles/pred.dir/util/getline.o CMakeFiles/pred.dir/util/random.o CMakeFiles/pred.dir/wind/wind_file_cache.o CMakeFiles/pred.dir/wind/wind_file.o CMakeFiles/pred.dir/altitude.o CMakeFiles/pred.dir/pred.o CMakeFiles/pred.dir/run_model.o CMakeFiles/pred.dir/ini/iniparser.o CMakeFiles/pred.dir/ini/dictionary.o -o pred -rdynamic -lglib-2.0 -lm diff --git a/pred_src/CMakeFiles/pred.dir/pred.o b/pred_src/CMakeFiles/pred.dir/pred.o new file mode 100644 index 0000000..ff1d16c Binary files /dev/null and b/pred_src/CMakeFiles/pred.dir/pred.o differ diff --git a/pred_src/CMakeFiles/pred.dir/progress.make b/pred_src/CMakeFiles/pred.dir/progress.make new file mode 100644 index 0000000..eeadf29 --- /dev/null +++ b/pred_src/CMakeFiles/pred.dir/progress.make @@ -0,0 +1,12 @@ +CMAKE_PROGRESS_1 = 1 +CMAKE_PROGRESS_2 = 2 +CMAKE_PROGRESS_3 = 3 +CMAKE_PROGRESS_4 = 4 +CMAKE_PROGRESS_5 = 5 +CMAKE_PROGRESS_6 = 6 +CMAKE_PROGRESS_7 = 7 +CMAKE_PROGRESS_8 = 8 +CMAKE_PROGRESS_9 = 9 +CMAKE_PROGRESS_10 = 10 +CMAKE_PROGRESS_11 = 11 + diff --git a/pred_src/CMakeFiles/pred.dir/run_model.o b/pred_src/CMakeFiles/pred.dir/run_model.o new file mode 100644 index 0000000..5ac21aa Binary files /dev/null and b/pred_src/CMakeFiles/pred.dir/run_model.o differ diff --git a/pred_src/CMakeFiles/pred.dir/util/getdelim.o b/pred_src/CMakeFiles/pred.dir/util/getdelim.o new file mode 100644 index 0000000..a85dc28 Binary files /dev/null and b/pred_src/CMakeFiles/pred.dir/util/getdelim.o differ diff --git a/pred_src/CMakeFiles/pred.dir/util/getline.o b/pred_src/CMakeFiles/pred.dir/util/getline.o new file mode 100644 index 0000000..ba56968 Binary files /dev/null and b/pred_src/CMakeFiles/pred.dir/util/getline.o differ diff --git a/pred_src/CMakeFiles/pred.dir/util/gopt.o b/pred_src/CMakeFiles/pred.dir/util/gopt.o new file mode 100644 index 0000000..7b560f8 Binary files /dev/null and b/pred_src/CMakeFiles/pred.dir/util/gopt.o differ diff --git a/pred_src/CMakeFiles/pred.dir/util/random.o b/pred_src/CMakeFiles/pred.dir/util/random.o new file mode 100644 index 0000000..8e5eeaf Binary files /dev/null and b/pred_src/CMakeFiles/pred.dir/util/random.o differ diff --git a/pred_src/CMakeFiles/pred.dir/wind/wind_file.o b/pred_src/CMakeFiles/pred.dir/wind/wind_file.o new file mode 100644 index 0000000..675cd84 Binary files /dev/null and b/pred_src/CMakeFiles/pred.dir/wind/wind_file.o differ diff --git a/pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.o b/pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.o new file mode 100644 index 0000000..14fed0a Binary files /dev/null and b/pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.o differ diff --git a/pred_src/CMakeFiles/progress.make b/pred_src/CMakeFiles/progress.make new file mode 100644 index 0000000..b4de394 --- /dev/null +++ b/pred_src/CMakeFiles/progress.make @@ -0,0 +1 @@ +11 diff --git a/pred_src/CMakeLists.txt b/pred_src/CMakeLists.txt new file mode 100644 index 0000000..c6665fb --- /dev/null +++ b/pred_src/CMakeLists.txt @@ -0,0 +1,38 @@ +# CMake build file for the CUSF landing prediction software +# +# Original version: Rich Wareham + +# Use PkgConfig to find the glib libraries +find_package(PkgConfig) + +pkg_check_modules(GLIB REQUIRED glib-2.0) + +include_directories(${GLIB_INCLUDE_DIRS}) +link_directories(${GLIB_LIBRARY_DIRS}) + +add_executable(pred + util/gopt.c + util/getdelim.c + util/random.h + util/gopt.h + util/getline.h + util/getline.c + util/getdelim.h + util/random.c + altitude.h + wind/wind_file_cache.c + wind/wind_file_cache.h + wind/wind_file.c + wind/wind_file.h + altitude.c + pred.c + run_model.c + pred.h + run_model.h + ini/iniparser.c + ini/iniparser.h + ini/dictionary.h + ini/dictionary.c +) + +target_link_libraries(pred ${GLIB_LIBRARIES} -lm) diff --git a/pred_src/Makefile b/pred_src/Makefile new file mode 100644 index 0000000..099b5e0 --- /dev/null +++ b/pred_src/Makefile @@ -0,0 +1,335 @@ +# CMAKE generated file: DO NOT EDIT! +# Generated by "Unix Makefiles" Generator, CMake Version 2.6 + +# Default target executed when no arguments are given to make. +default_target: all +.PHONY : default_target + +#============================================================================= +# Special targets provided by cmake. + +# Disable implicit rules so canoncical targets will work. +.SUFFIXES: + +# Remove some rules from gmake that .SUFFIXES does not remove. +SUFFIXES = + +.SUFFIXES: .hpux_make_needs_suffix_list + +# Suppress display of executed commands. +$(VERBOSE).SILENT: + +# A target that is always out of date. +cmake_force: +.PHONY : cmake_force + +#============================================================================= +# Set environment variables for the build. + +# The shell in which to execute make rules. +SHELL = /bin/sh + +# The CMake executable. +CMAKE_COMMAND = /usr/bin/cmake + +# The command to remove a file. +RM = /usr/bin/cmake -E remove -f + +# The program to use to edit the cache. +CMAKE_EDIT_COMMAND = /usr/bin/ccmake + +# The top-level source directory on which CMake was run. +CMAKE_SOURCE_DIR = /var/hab/cusf-landing-prediction + +# The top-level build directory on which CMake was run. +CMAKE_BINARY_DIR = /var/hab/cusf-landing-prediction + +#============================================================================= +# Targets provided globally by CMake. + +# Special rule for the target edit_cache +edit_cache: + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..." + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/ccmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) +.PHONY : edit_cache + +# Special rule for the target edit_cache +edit_cache/fast: edit_cache +.PHONY : edit_cache/fast + +# Special rule for the target rebuild_cache +rebuild_cache: + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." + cd /var/hab/cusf-landing-prediction/pred_src && /usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) +.PHONY : rebuild_cache + +# Special rule for the target rebuild_cache +rebuild_cache/fast: rebuild_cache +.PHONY : rebuild_cache/fast + +# The main all target +all: cmake_check_build_system + cd /var/hab/cusf-landing-prediction && $(CMAKE_COMMAND) -E cmake_progress_start /var/hab/cusf-landing-prediction/CMakeFiles /var/hab/cusf-landing-prediction/pred_src/CMakeFiles/progress.make + cd /var/hab/cusf-landing-prediction && $(MAKE) -f CMakeFiles/Makefile2 pred_src/all + $(CMAKE_COMMAND) -E cmake_progress_start /var/hab/cusf-landing-prediction/CMakeFiles 0 +.PHONY : all + +# The main clean target +clean: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f CMakeFiles/Makefile2 pred_src/clean +.PHONY : clean + +# The main clean target +clean/fast: clean +.PHONY : clean/fast + +# Prepare targets for installation. +preinstall: all + cd /var/hab/cusf-landing-prediction && $(MAKE) -f CMakeFiles/Makefile2 pred_src/preinstall +.PHONY : preinstall + +# Prepare targets for installation. +preinstall/fast: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f CMakeFiles/Makefile2 pred_src/preinstall +.PHONY : preinstall/fast + +# clear depends +depend: + cd /var/hab/cusf-landing-prediction && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 +.PHONY : depend + +# Convenience name for target. +pred_src/CMakeFiles/pred.dir/rule: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f CMakeFiles/Makefile2 pred_src/CMakeFiles/pred.dir/rule +.PHONY : pred_src/CMakeFiles/pred.dir/rule + +# Convenience name for target. +pred: pred_src/CMakeFiles/pred.dir/rule +.PHONY : pred + +# fast build rule for target. +pred/fast: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/build +.PHONY : pred/fast + +# target to build an object file +altitude.o: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/altitude.o +.PHONY : altitude.o + +# target to preprocess a source file +altitude.i: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/altitude.i +.PHONY : altitude.i + +# target to generate assembly for a file +altitude.s: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/altitude.s +.PHONY : altitude.s + +# target to build an object file +ini/dictionary.o: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/ini/dictionary.o +.PHONY : ini/dictionary.o + +# target to preprocess a source file +ini/dictionary.i: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/ini/dictionary.i +.PHONY : ini/dictionary.i + +# target to generate assembly for a file +ini/dictionary.s: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/ini/dictionary.s +.PHONY : ini/dictionary.s + +# target to build an object file +ini/iniparser.o: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/ini/iniparser.o +.PHONY : ini/iniparser.o + +# target to preprocess a source file +ini/iniparser.i: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/ini/iniparser.i +.PHONY : ini/iniparser.i + +# target to generate assembly for a file +ini/iniparser.s: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/ini/iniparser.s +.PHONY : ini/iniparser.s + +# target to build an object file +pred.o: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/pred.o +.PHONY : pred.o + +# target to preprocess a source file +pred.i: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/pred.i +.PHONY : pred.i + +# target to generate assembly for a file +pred.s: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/pred.s +.PHONY : pred.s + +# target to build an object file +run_model.o: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/run_model.o +.PHONY : run_model.o + +# target to preprocess a source file +run_model.i: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/run_model.i +.PHONY : run_model.i + +# target to generate assembly for a file +run_model.s: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/run_model.s +.PHONY : run_model.s + +# target to build an object file +util/getdelim.o: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/util/getdelim.o +.PHONY : util/getdelim.o + +# target to preprocess a source file +util/getdelim.i: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/util/getdelim.i +.PHONY : util/getdelim.i + +# target to generate assembly for a file +util/getdelim.s: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/util/getdelim.s +.PHONY : util/getdelim.s + +# target to build an object file +util/getline.o: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/util/getline.o +.PHONY : util/getline.o + +# target to preprocess a source file +util/getline.i: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/util/getline.i +.PHONY : util/getline.i + +# target to generate assembly for a file +util/getline.s: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/util/getline.s +.PHONY : util/getline.s + +# target to build an object file +util/gopt.o: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/util/gopt.o +.PHONY : util/gopt.o + +# target to preprocess a source file +util/gopt.i: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/util/gopt.i +.PHONY : util/gopt.i + +# target to generate assembly for a file +util/gopt.s: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/util/gopt.s +.PHONY : util/gopt.s + +# target to build an object file +util/random.o: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/util/random.o +.PHONY : util/random.o + +# target to preprocess a source file +util/random.i: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/util/random.i +.PHONY : util/random.i + +# target to generate assembly for a file +util/random.s: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/util/random.s +.PHONY : util/random.s + +# target to build an object file +wind/wind_file.o: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/wind/wind_file.o +.PHONY : wind/wind_file.o + +# target to preprocess a source file +wind/wind_file.i: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/wind/wind_file.i +.PHONY : wind/wind_file.i + +# target to generate assembly for a file +wind/wind_file.s: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/wind/wind_file.s +.PHONY : wind/wind_file.s + +# target to build an object file +wind/wind_file_cache.o: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.o +.PHONY : wind/wind_file_cache.o + +# target to preprocess a source file +wind/wind_file_cache.i: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.i +.PHONY : wind/wind_file_cache.i + +# target to generate assembly for a file +wind/wind_file_cache.s: + cd /var/hab/cusf-landing-prediction && $(MAKE) -f pred_src/CMakeFiles/pred.dir/build.make pred_src/CMakeFiles/pred.dir/wind/wind_file_cache.s +.PHONY : wind/wind_file_cache.s + +# Help Target +help: + @echo "The following are some of the valid targets for this Makefile:" + @echo "... all (the default if no target is provided)" + @echo "... clean" + @echo "... depend" + @echo "... edit_cache" + @echo "... pred" + @echo "... rebuild_cache" + @echo "... altitude.o" + @echo "... altitude.i" + @echo "... altitude.s" + @echo "... ini/dictionary.o" + @echo "... ini/dictionary.i" + @echo "... ini/dictionary.s" + @echo "... ini/iniparser.o" + @echo "... ini/iniparser.i" + @echo "... ini/iniparser.s" + @echo "... pred.o" + @echo "... pred.i" + @echo "... pred.s" + @echo "... run_model.o" + @echo "... run_model.i" + @echo "... run_model.s" + @echo "... util/getdelim.o" + @echo "... util/getdelim.i" + @echo "... util/getdelim.s" + @echo "... util/getline.o" + @echo "... util/getline.i" + @echo "... util/getline.s" + @echo "... util/gopt.o" + @echo "... util/gopt.i" + @echo "... util/gopt.s" + @echo "... util/random.o" + @echo "... util/random.i" + @echo "... util/random.s" + @echo "... wind/wind_file.o" + @echo "... wind/wind_file.i" + @echo "... wind/wind_file.s" + @echo "... wind/wind_file_cache.o" + @echo "... wind/wind_file_cache.i" + @echo "... wind/wind_file_cache.s" +.PHONY : help + + + +#============================================================================= +# Special targets to cleanup operation of make. + +# Special rule to run CMake to check the build system integrity. +# No rule that depends on this can have commands that come from listfiles +# because they might be regenerated. +cmake_check_build_system: + cd /var/hab/cusf-landing-prediction && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 +.PHONY : cmake_check_build_system + diff --git a/pred_src/altitude.c b/pred_src/altitude.c new file mode 100644 index 0000000..b58214c --- /dev/null +++ b/pred_src/altitude.c @@ -0,0 +1,126 @@ +// -------------------------------------------------------------- +// CU Spaceflight Landing Prediction +// Copyright (c) CU Spaceflight 2009, All Right Reserved +// +// Written by Rob Anderson +// Modified by Fergus Noble +// +// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY +// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// -------------------------------------------------------------- + +#include +#include +#include + +#include "pred.h" +#include "altitude.h" +#include "run_model.h" + +// get density of atmosphere at a given altitude +// uses NASA model from http://www.grc.nasa.gov/WWW/K-12/airplane/atmosmet.html +// units of degrees celcius, metres, KPa and Kg/metre cubed +static float get_density(float altitude); + +#define G 9.8 + +struct altitude_model_s +{ + float burst_altitude; + float ascent_rate; + float drag_coeff; + int descent_mode; + + float initial_alt; + int burst_time; +}; + +altitude_model_t* +altitude_model_new(int dec_mode, float burst_alt, float asc_rate, float drag_co) +{ + altitude_model_t* self = (altitude_model_t*)malloc(sizeof(altitude_model_t)); + + // this function doesn't do anything much at the moment + // but will prove useful in the future + + self->burst_altitude = burst_alt; + self->ascent_rate = asc_rate; + self->drag_coeff = drag_co; + self->descent_mode = dec_mode; + + return self; +} + +void +altitude_model_free(altitude_model_t* self) +{ + if(!self) + return; + + free(self); +} + +int +altitude_model_get_altitude(altitude_model_t* self, int time_into_flight, float* alt) { + // TODO: this section needs some work to make it more flexible + + // time == 0 so setup initial altitude stuff + if (time_into_flight == 0) { + self->initial_alt = *alt; + self->burst_time = (self->burst_altitude - self->initial_alt) / self->ascent_rate; + } + + // If we are not doing a descending mode sim then start going up + // at out ascent rate. The ascent rate is constant to a good approximation. + if (self->descent_mode == DESCENT_MODE_NORMAL) + if (time_into_flight <= self->burst_time) { + *alt = self->initial_alt + time_into_flight*self->ascent_rate; + return 1; + } + + // Descent - just assume its at terminal velocity (which varies with altitude) + // this is a pretty darn good approximation for high-ish drag e.g. under parachute + // still converges to T.V. quickly (i.e. less than a minute) for low drag. + // terminal velocity = -drag_coeff/sqrt(get_density(*alt)); + *alt += TIMESTEP * -self->drag_coeff/sqrt(get_density(*alt)); + + /* + // Rob's method - is this just freefall until we reach terminal velocity? + vertical_speed = -drag_coeff/sqrt(get_density(*alt)); + // TODO: inaccurate if still accelerating + if (vertical_speed < previous_vertical_speed - G*TIMESTEP) // still accelerating + vertical_speed = previous_vertical_speed - G*TIMESTEP; + if(vertical_speed > previous_vertical_speed + G*TIMESTEP) // still accelerating + vertical_speed = previous_vertical_speed + G*TIMESTEP; + previous_vertical_speed = vertical_speed; + *alt += TIMESTEP * vertical_speed; + */ + + if (*alt <= 0) + return 0; + + return 1; + +} + +float get_density(float altitude) { + + float temp = 0.f, pressure = 0.f; + + if (altitude > 25000) { + temp = -131.21 + 0.00299 * altitude; + pressure = 2.488*pow((temp+273.1)/216.6,-11.388); + } + if (altitude <=25000 && altitude > 11000) { + temp = -56.46; + pressure = 22.65 * exp(1.73-0.000157*altitude); + } + if (altitude <=11000) { + temp = 15.04 - 0.00649 * altitude; + pressure = 101.29 * pow((temp + 273.1)/288.08,5.256); + } + + return pressure/(0.2869*(temp+273.1)); +} diff --git a/pred_src/altitude.h b/pred_src/altitude.h new file mode 100644 index 0000000..2d9326a --- /dev/null +++ b/pred_src/altitude.h @@ -0,0 +1,49 @@ +// -------------------------------------------------------------- +// CU Spaceflight Landing Prediction +// Copyright (c) CU Spaceflight 2009, All Right Reserved +// +// Written by Rob Anderson +// Modified by Fergus Noble +// +// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY +// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// -------------------------------------------------------------- + +#ifndef __ALTITUDE_H__ +#define __ALTITUDE_H__ + +typedef struct altitude_model_s altitude_model_t; + +// create an altitude/time model with given parameters, must be called before +// calling run_model if descent_mode is DESCENT_MODE_DESCENDING then we start +// off with the balloon descending i.e. after burst +altitude_model_t *altitude_model_new (int descent_mode, + float burst_alt, + float ascent_rate, + float drag_coeff); + +// free resources associated with the specified altitude model. +void altitude_model_free (altitude_model_t *model); + +// returns the altitude corresponding to a certain time into the flight (in seconds) +// the result it stored in the alt variable. +// the contents of alt when the function is called with time_into_flight = 0 +// will be taken as the starting altitude returns 1 normally and 0 when the +// flight has terminated +int altitude_model_get_altitude + (altitude_model_t *model, + int time_into_flight, + float *alt); + + + +// it seems like overkill to do it this way but it is in preparation for being able to load in +// arbitrary altitude/time profiles from a file + +#define DESCENT_MODE_DESCENDING 1 +#define DESCENT_MODE_NORMAL 0 + +#endif // __ALTITUDE_H__ + diff --git a/pred_src/cmake_install.cmake b/pred_src/cmake_install.cmake new file mode 100644 index 0000000..faf8028 --- /dev/null +++ b/pred_src/cmake_install.cmake @@ -0,0 +1,34 @@ +# Install script for directory: /var/hab/cusf-landing-prediction/pred_src + +# Set the install prefix +IF(NOT DEFINED CMAKE_INSTALL_PREFIX) + SET(CMAKE_INSTALL_PREFIX "/usr/local") +ENDIF(NOT DEFINED CMAKE_INSTALL_PREFIX) +STRING(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") + +# Set the install configuration name. +IF(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) + IF(BUILD_TYPE) + STRING(REGEX REPLACE "^[^A-Za-z0-9_]+" "" + CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") + ELSE(BUILD_TYPE) + SET(CMAKE_INSTALL_CONFIG_NAME "") + ENDIF(BUILD_TYPE) + MESSAGE(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") +ENDIF(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) + +# Set the component getting installed. +IF(NOT CMAKE_INSTALL_COMPONENT) + IF(COMPONENT) + MESSAGE(STATUS "Install component: \"${COMPONENT}\"") + SET(CMAKE_INSTALL_COMPONENT "${COMPONENT}") + ELSE(COMPONENT) + SET(CMAKE_INSTALL_COMPONENT) + ENDIF(COMPONENT) +ENDIF(NOT CMAKE_INSTALL_COMPONENT) + +# Install shared libraries without execute permission? +IF(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE) + SET(CMAKE_INSTALL_SO_NO_EXE "1") +ENDIF(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE) + diff --git a/pred_src/ini/LICENSE b/pred_src/ini/LICENSE new file mode 100644 index 0000000..dbfa45d --- /dev/null +++ b/pred_src/ini/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) 2000-2007 by Nicolas Devillard. +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + diff --git a/pred_src/ini/README b/pred_src/ini/README new file mode 100644 index 0000000..f79159f --- /dev/null +++ b/pred_src/ini/README @@ -0,0 +1,4 @@ +These files from from the iniparser project[1] and are released under the MIT +license which may be found in the associated LICENSE file. + +[1] http://ndevilla.free.fr/iniparser/ diff --git a/pred_src/ini/README.orig b/pred_src/ini/README.orig new file mode 100644 index 0000000..acb73ce --- /dev/null +++ b/pred_src/ini/README.orig @@ -0,0 +1,12 @@ + +Welcome to iniParser -- version 3.0b (beta) +released 03 Jan 2008 + +This modules offers parsing of ini files from the C level. +See a complete documentation in HTML format, from this directory +open the file html/index.html with any HTML-capable browser. + +Enjoy! + +N.Devillard +Thu Jan 3 19:36:31 CET 2008 diff --git a/pred_src/ini/dictionary.c b/pred_src/ini/dictionary.c new file mode 100644 index 0000000..b7c9ebf --- /dev/null +++ b/pred_src/ini/dictionary.c @@ -0,0 +1,405 @@ +/*-------------------------------------------------------------------------*/ +/** + @file dictionary.c + @author N. Devillard + @date Sep 2007 + @version $Revision: 1.27 $ + @brief Implements a dictionary for string variables. + + This module implements a simple dictionary object, i.e. a list + of string/string associations. This object is useful to store e.g. + informations retrieved from a configuration file (ini files). +*/ +/*--------------------------------------------------------------------------*/ + +/* + $Id: dictionary.c,v 1.27 2007-11-23 21:39:18 ndevilla Exp $ + $Revision: 1.27 $ +*/ +/*--------------------------------------------------------------------------- + Includes + ---------------------------------------------------------------------------*/ +#include "dictionary.h" + +#include +#include +#include +#include + +/** Maximum value size for integers and doubles. */ +#define MAXVALSZ 1024 + +/** Minimal allocated number of entries in a dictionary */ +#define DICTMINSZ 128 + +/** Invalid key token */ +#define DICT_INVALID_KEY ((char*)-1) + +/*--------------------------------------------------------------------------- + Private functions + ---------------------------------------------------------------------------*/ + +/* Doubles the allocated size associated to a pointer */ +/* 'size' is the current allocated size. */ +static void * mem_double(void * ptr, int size) +{ + void * newptr ; + + newptr = calloc(2*size, 1); + if (newptr==NULL) { + return NULL ; + } + memcpy(newptr, ptr, size); + free(ptr); + return newptr ; +} + +/*-------------------------------------------------------------------------*/ +/** + @brief Duplicate a string + @param s String to duplicate + @return Pointer to a newly allocated string, to be freed with free() + + This is a replacement for strdup(). This implementation is provided + for systems that do not have it. + */ +/*--------------------------------------------------------------------------*/ +static char * xstrdup(char * s) +{ + char * t ; + if (!s) + return NULL ; + t = malloc(strlen(s)+1) ; + if (t) { + strcpy(t,s); + } + return t ; +} + +/*--------------------------------------------------------------------------- + Function codes + ---------------------------------------------------------------------------*/ +/*-------------------------------------------------------------------------*/ +/** + @brief Compute the hash key for a string. + @param key Character string to use for key. + @return 1 unsigned int on at least 32 bits. + + This hash function has been taken from an Article in Dr Dobbs Journal. + This is normally a collision-free function, distributing keys evenly. + The key is stored anyway in the struct so that collision can be avoided + by comparing the key itself in last resort. + */ +/*--------------------------------------------------------------------------*/ +unsigned dictionary_hash(char * key) +{ + int len ; + unsigned hash ; + int i ; + + len = strlen(key); + for (hash=0, i=0 ; i>6) ; + } + hash += (hash <<3); + hash ^= (hash >>11); + hash += (hash <<15); + return hash ; +} + +/*-------------------------------------------------------------------------*/ +/** + @brief Create a new dictionary object. + @param size Optional initial size of the dictionary. + @return 1 newly allocated dictionary objet. + + This function allocates a new dictionary object of given size and returns + it. If you do not know in advance (roughly) the number of entries in the + dictionary, give size=0. + */ +/*--------------------------------------------------------------------------*/ +dictionary * dictionary_new(int size) +{ + dictionary * d ; + + /* If no size was specified, allocate space for DICTMINSZ */ + if (sizesize = size ; + d->val = (char **)calloc(size, sizeof(char*)); + d->key = (char **)calloc(size, sizeof(char*)); + d->hash = (unsigned int *)calloc(size, sizeof(unsigned)); + return d ; +} + +/*-------------------------------------------------------------------------*/ +/** + @brief Delete a dictionary object + @param d dictionary object to deallocate. + @return void + + Deallocate a dictionary object and all memory associated to it. + */ +/*--------------------------------------------------------------------------*/ +void dictionary_del(dictionary * d) +{ + int i ; + + if (d==NULL) return ; + for (i=0 ; isize ; i++) { + if (d->key[i]!=NULL) + free(d->key[i]); + if (d->val[i]!=NULL) + free(d->val[i]); + } + free(d->val); + free(d->key); + free(d->hash); + free(d); + return ; +} + +/*-------------------------------------------------------------------------*/ +/** + @brief Get a value from a dictionary. + @param d dictionary object to search. + @param key Key to look for in the dictionary. + @param def Default value to return if key not found. + @return 1 pointer to internally allocated character string. + + This function locates a key in a dictionary and returns a pointer to its + value, or the passed 'def' pointer if no such key can be found in + dictionary. The returned character pointer points to data internal to the + dictionary object, you should not try to free it or modify it. + */ +/*--------------------------------------------------------------------------*/ +char * dictionary_get(dictionary * d, char * key, char * def) +{ + unsigned hash ; + int i ; + + hash = dictionary_hash(key); + for (i=0 ; isize ; i++) { + if (d->key[i]==NULL) + continue ; + /* Compare hash */ + if (hash==d->hash[i]) { + /* Compare string, to avoid hash collisions */ + if (!strcmp(key, d->key[i])) { + return d->val[i] ; + } + } + } + return def ; +} + +/*-------------------------------------------------------------------------*/ +/** + @brief Set a value in a dictionary. + @param d dictionary object to modify. + @param key Key to modify or add. + @param val Value to add. + @return int 0 if Ok, anything else otherwise + + If the given key is found in the dictionary, the associated value is + replaced by the provided one. If the key cannot be found in the + dictionary, it is added to it. + + It is Ok to provide a NULL value for val, but NULL values for the dictionary + or the key are considered as errors: the function will return immediately + in such a case. + + Notice that if you dictionary_set a variable to NULL, a call to + dictionary_get will return a NULL value: the variable will be found, and + its value (NULL) is returned. In other words, setting the variable + content to NULL is equivalent to deleting the variable from the + dictionary. It is not possible (in this implementation) to have a key in + the dictionary without value. + + This function returns non-zero in case of failure. + */ +/*--------------------------------------------------------------------------*/ +int dictionary_set(dictionary * d, char * key, char * val) +{ + int i ; + unsigned hash ; + + if (d==NULL || key==NULL) return -1 ; + + /* Compute hash for this key */ + hash = dictionary_hash(key) ; + /* Find if value is already in dictionary */ + if (d->n>0) { + for (i=0 ; isize ; i++) { + if (d->key[i]==NULL) + continue ; + if (hash==d->hash[i]) { /* Same hash value */ + if (!strcmp(key, d->key[i])) { /* Same key */ + /* Found a value: modify and return */ + if (d->val[i]!=NULL) + free(d->val[i]); + d->val[i] = val ? xstrdup(val) : NULL ; + /* Value has been modified: return */ + return 0 ; + } + } + } + } + /* Add a new value */ + /* See if dictionary needs to grow */ + if (d->n==d->size) { + + /* Reached maximum size: reallocate dictionary */ + d->val = (char **)mem_double(d->val, d->size * sizeof(char*)) ; + d->key = (char **)mem_double(d->key, d->size * sizeof(char*)) ; + d->hash = (unsigned int *)mem_double(d->hash, d->size * sizeof(unsigned)) ; + if ((d->val==NULL) || (d->key==NULL) || (d->hash==NULL)) { + /* Cannot grow dictionary */ + return -1 ; + } + /* Double size */ + d->size *= 2 ; + } + + /* Insert key in the first empty slot */ + for (i=0 ; isize ; i++) { + if (d->key[i]==NULL) { + /* Add key here */ + break ; + } + } + /* Copy key */ + d->key[i] = xstrdup(key); + d->val[i] = val ? xstrdup(val) : NULL ; + d->hash[i] = hash; + d->n ++ ; + return 0 ; +} + +/*-------------------------------------------------------------------------*/ +/** + @brief Delete a key in a dictionary + @param d dictionary object to modify. + @param key Key to remove. + @return void + + This function deletes a key in a dictionary. Nothing is done if the + key cannot be found. + */ +/*--------------------------------------------------------------------------*/ +void dictionary_unset(dictionary * d, char * key) +{ + unsigned hash ; + int i ; + + if (key == NULL) { + return; + } + + hash = dictionary_hash(key); + for (i=0 ; isize ; i++) { + if (d->key[i]==NULL) + continue ; + /* Compare hash */ + if (hash==d->hash[i]) { + /* Compare string, to avoid hash collisions */ + if (!strcmp(key, d->key[i])) { + /* Found key */ + break ; + } + } + } + if (i>=d->size) + /* Key not found */ + return ; + + free(d->key[i]); + d->key[i] = NULL ; + if (d->val[i]!=NULL) { + free(d->val[i]); + d->val[i] = NULL ; + } + d->hash[i] = 0 ; + d->n -- ; + return ; +} + +/*-------------------------------------------------------------------------*/ +/** + @brief Dump a dictionary to an opened file pointer. + @param d Dictionary to dump + @param f Opened file pointer. + @return void + + Dumps a dictionary onto an opened file pointer. Key pairs are printed out + as @c [Key]=[Value], one per line. It is Ok to provide stdout or stderr as + output file pointers. + */ +/*--------------------------------------------------------------------------*/ +void dictionary_dump(dictionary * d, FILE * out) +{ + int i ; + + if (d==NULL || out==NULL) return ; + if (d->n<1) { + fprintf(out, "empty dictionary\n"); + return ; + } + for (i=0 ; isize ; i++) { + if (d->key[i]) { + fprintf(out, "%20s\t[%s]\n", + d->key[i], + d->val[i] ? d->val[i] : "UNDEF"); + } + } + return ; +} + + +/* Test code */ +#ifdef TESTDIC +#define NVALS 20000 +int main(int argc, char *argv[]) +{ + dictionary * d ; + char * val ; + int i ; + char cval[90] ; + + /* Allocate dictionary */ + printf("allocating...\n"); + d = dictionary_new(0); + + /* Set values in dictionary */ + printf("setting %d values...\n", NVALS); + for (i=0 ; in != 0) { + printf("error deleting values\n"); + } + printf("deallocating...\n"); + dictionary_del(d); + return 0 ; +} +#endif +/* vim: set ts=4 et sw=4 tw=75 */ diff --git a/pred_src/ini/dictionary.h b/pred_src/ini/dictionary.h new file mode 100644 index 0000000..c7d1790 --- /dev/null +++ b/pred_src/ini/dictionary.h @@ -0,0 +1,174 @@ + +/*-------------------------------------------------------------------------*/ +/** + @file dictionary.h + @author N. Devillard + @date Sep 2007 + @version $Revision: 1.12 $ + @brief Implements a dictionary for string variables. + + This module implements a simple dictionary object, i.e. a list + of string/string associations. This object is useful to store e.g. + informations retrieved from a configuration file (ini files). +*/ +/*--------------------------------------------------------------------------*/ + +/* + $Id: dictionary.h,v 1.12 2007-11-23 21:37:00 ndevilla Exp $ + $Author: ndevilla $ + $Date: 2007-11-23 21:37:00 $ + $Revision: 1.12 $ +*/ + +#ifndef _DICTIONARY_H_ +#define _DICTIONARY_H_ + +/*--------------------------------------------------------------------------- + Includes + ---------------------------------------------------------------------------*/ + +#include +#include +#include +#include + +/*--------------------------------------------------------------------------- + New types + ---------------------------------------------------------------------------*/ + + +/*-------------------------------------------------------------------------*/ +/** + @brief Dictionary object + + This object contains a list of string/string associations. Each + association is identified by a unique string key. Looking up values + in the dictionary is speeded up by the use of a (hopefully collision-free) + hash function. + */ +/*-------------------------------------------------------------------------*/ +typedef struct _dictionary_ { + int n ; /** Number of entries in dictionary */ + int size ; /** Storage size */ + char ** val ; /** List of string values */ + char ** key ; /** List of string keys */ + unsigned * hash ; /** List of hash values for keys */ +} dictionary ; + + +/*--------------------------------------------------------------------------- + Function prototypes + ---------------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------------*/ +/** + @brief Compute the hash key for a string. + @param key Character string to use for key. + @return 1 unsigned int on at least 32 bits. + + This hash function has been taken from an Article in Dr Dobbs Journal. + This is normally a collision-free function, distributing keys evenly. + The key is stored anyway in the struct so that collision can be avoided + by comparing the key itself in last resort. + */ +/*--------------------------------------------------------------------------*/ +unsigned dictionary_hash(char * key); + +/*-------------------------------------------------------------------------*/ +/** + @brief Create a new dictionary object. + @param size Optional initial size of the dictionary. + @return 1 newly allocated dictionary objet. + + This function allocates a new dictionary object of given size and returns + it. If you do not know in advance (roughly) the number of entries in the + dictionary, give size=0. + */ +/*--------------------------------------------------------------------------*/ +dictionary * dictionary_new(int size); + +/*-------------------------------------------------------------------------*/ +/** + @brief Delete a dictionary object + @param d dictionary object to deallocate. + @return void + + Deallocate a dictionary object and all memory associated to it. + */ +/*--------------------------------------------------------------------------*/ +void dictionary_del(dictionary * vd); + +/*-------------------------------------------------------------------------*/ +/** + @brief Get a value from a dictionary. + @param d dictionary object to search. + @param key Key to look for in the dictionary. + @param def Default value to return if key not found. + @return 1 pointer to internally allocated character string. + + This function locates a key in a dictionary and returns a pointer to its + value, or the passed 'def' pointer if no such key can be found in + dictionary. The returned character pointer points to data internal to the + dictionary object, you should not try to free it or modify it. + */ +/*--------------------------------------------------------------------------*/ +char * dictionary_get(dictionary * d, char * key, char * def); + + +/*-------------------------------------------------------------------------*/ +/** + @brief Set a value in a dictionary. + @param d dictionary object to modify. + @param key Key to modify or add. + @param val Value to add. + @return int 0 if Ok, anything else otherwise + + If the given key is found in the dictionary, the associated value is + replaced by the provided one. If the key cannot be found in the + dictionary, it is added to it. + + It is Ok to provide a NULL value for val, but NULL values for the dictionary + or the key are considered as errors: the function will return immediately + in such a case. + + Notice that if you dictionary_set a variable to NULL, a call to + dictionary_get will return a NULL value: the variable will be found, and + its value (NULL) is returned. In other words, setting the variable + content to NULL is equivalent to deleting the variable from the + dictionary. It is not possible (in this implementation) to have a key in + the dictionary without value. + + This function returns non-zero in case of failure. + */ +/*--------------------------------------------------------------------------*/ +int dictionary_set(dictionary * vd, char * key, char * val); + +/*-------------------------------------------------------------------------*/ +/** + @brief Delete a key in a dictionary + @param d dictionary object to modify. + @param key Key to remove. + @return void + + This function deletes a key in a dictionary. Nothing is done if the + key cannot be found. + */ +/*--------------------------------------------------------------------------*/ +void dictionary_unset(dictionary * d, char * key); + + +/*-------------------------------------------------------------------------*/ +/** + @brief Dump a dictionary to an opened file pointer. + @param d Dictionary to dump + @param f Opened file pointer. + @return void + + Dumps a dictionary onto an opened file pointer. Key pairs are printed out + as @c [Key]=[Value], one per line. It is Ok to provide stdout or stderr as + output file pointers. + */ +/*--------------------------------------------------------------------------*/ +void dictionary_dump(dictionary * d, FILE * out); + +#endif diff --git a/pred_src/ini/iniparser.c b/pred_src/ini/iniparser.c new file mode 100644 index 0000000..8caacd1 --- /dev/null +++ b/pred_src/ini/iniparser.c @@ -0,0 +1,668 @@ + +/*-------------------------------------------------------------------------*/ +/** + @file iniparser.c + @author N. Devillard + @date Sep 2007 + @version 3.0 + @brief Parser for ini files. +*/ +/*--------------------------------------------------------------------------*/ +/* + $Id: iniparser.c,v 2.18 2008-01-03 18:35:39 ndevilla Exp $ + $Revision: 2.18 $ + $Date: 2008-01-03 18:35:39 $ +*/ +/*---------------------------- Includes ------------------------------------*/ +#include +#include "iniparser.h" + +/*---------------------------- Defines -------------------------------------*/ +#define ASCIILINESZ (1024) +#define INI_INVALID_KEY ((char*)-1) + +/*--------------------------------------------------------------------------- + Private to this module + ---------------------------------------------------------------------------*/ +/** + * This enum stores the status for each parsed line (internal use only). + */ +typedef enum _line_status_ { + LINE_UNPROCESSED, + LINE_ERROR, + LINE_EMPTY, + LINE_COMMENT, + LINE_SECTION, + LINE_VALUE +} line_status ; + +/*-------------------------------------------------------------------------*/ +/** + @brief Convert a string to lowercase. + @param s String to convert. + @return ptr to statically allocated string. + + This function returns a pointer to a statically allocated string + containing a lowercased version of the input string. Do not free + or modify the returned string! Since the returned string is statically + allocated, it will be modified at each function call (not re-entrant). + */ +/*--------------------------------------------------------------------------*/ +static char * strlwc(const char * s) +{ + static char l[ASCIILINESZ+1]; + int i ; + + if (s==NULL) return NULL ; + memset(l, 0, ASCIILINESZ+1); + i=0 ; + while (s[i] && i l) { + if (!isspace((int)*(last-1))) + break ; + last -- ; + } + *last = (char)0; + return (char*)l ; +} + +/*-------------------------------------------------------------------------*/ +/** + @brief Get number of sections in a dictionary + @param d Dictionary to examine + @return int Number of sections found in dictionary + + This function returns the number of sections found in a dictionary. + The test to recognize sections is done on the string stored in the + dictionary: a section name is given as "section" whereas a key is + stored as "section:key", thus the test looks for entries that do not + contain a colon. + + This clearly fails in the case a section name contains a colon, but + this should simply be avoided. + + This function returns -1 in case of error. + */ +/*--------------------------------------------------------------------------*/ +int iniparser_getnsec(dictionary * d) +{ + int i ; + int nsec ; + + if (d==NULL) return -1 ; + nsec=0 ; + for (i=0 ; isize ; i++) { + if (d->key[i]==NULL) + continue ; + if (strchr(d->key[i], ':')==NULL) { + nsec ++ ; + } + } + return nsec ; +} + +/*-------------------------------------------------------------------------*/ +/** + @brief Get name for section n in a dictionary. + @param d Dictionary to examine + @param n Section number (from 0 to nsec-1). + @return Pointer to char string + + This function locates the n-th section in a dictionary and returns + its name as a pointer to a string statically allocated inside the + dictionary. Do not free or modify the returned string! + + This function returns NULL in case of error. + */ +/*--------------------------------------------------------------------------*/ +char * iniparser_getsecname(dictionary * d, int n) +{ + int i ; + int foundsec ; + + if (d==NULL || n<0) return NULL ; + foundsec=0 ; + for (i=0 ; isize ; i++) { + if (d->key[i]==NULL) + continue ; + if (strchr(d->key[i], ':')==NULL) { + foundsec++ ; + if (foundsec>n) + break ; + } + } + if (foundsec<=n) { + return NULL ; + } + return d->key[i] ; +} + +/*-------------------------------------------------------------------------*/ +/** + @brief Dump a dictionary to an opened file pointer. + @param d Dictionary to dump. + @param f Opened file pointer to dump to. + @return void + + This function prints out the contents of a dictionary, one element by + line, onto the provided file pointer. It is OK to specify @c stderr + or @c stdout as output files. This function is meant for debugging + purposes mostly. + */ +/*--------------------------------------------------------------------------*/ +void iniparser_dump(dictionary * d, FILE * f) +{ + int i ; + + if (d==NULL || f==NULL) return ; + for (i=0 ; isize ; i++) { + if (d->key[i]==NULL) + continue ; + if (d->val[i]!=NULL) { + fprintf(f, "[%s]=[%s]\n", d->key[i], d->val[i]); + } else { + fprintf(f, "[%s]=UNDEF\n", d->key[i]); + } + } + return ; +} + +/*-------------------------------------------------------------------------*/ +/** + @brief Save a dictionary to a loadable ini file + @param d Dictionary to dump + @param f Opened file pointer to dump to + @return void + + This function dumps a given dictionary into a loadable ini file. + It is Ok to specify @c stderr or @c stdout as output files. + */ +/*--------------------------------------------------------------------------*/ +void iniparser_dump_ini(dictionary * d, FILE * f) +{ + int i, j ; + char keym[ASCIILINESZ+1]; + int nsec ; + char * secname ; + int seclen ; + + if (d==NULL || f==NULL) return ; + + nsec = iniparser_getnsec(d); + if (nsec<1) { + /* No section in file: dump all keys as they are */ + for (i=0 ; isize ; i++) { + if (d->key[i]==NULL) + continue ; + fprintf(f, "%s = %s\n", d->key[i], d->val[i]); + } + return ; + } + for (i=0 ; isize ; j++) { + if (d->key[j]==NULL) + continue ; + if (!strncmp(d->key[j], keym, seclen+1)) { + fprintf(f, + "%-30s = %s\n", + d->key[j]+seclen+1, + d->val[j] ? d->val[j] : ""); + } + } + } + fprintf(f, "\n"); + return ; +} + +/*-------------------------------------------------------------------------*/ +/** + @brief Get the string associated to a key + @param d Dictionary to search + @param key Key string to look for + @param def Default value to return if key not found. + @return pointer to statically allocated character string + + This function queries a dictionary for a key. A key as read from an + ini file is given as "section:key". If the key cannot be found, + the pointer passed as 'def' is returned. + The returned char pointer is pointing to a string allocated in + the dictionary, do not free or modify it. + */ +/*--------------------------------------------------------------------------*/ +char * iniparser_getstring(dictionary * d, const char * key, char * def) +{ + char * lc_key ; + char * sval ; + + if (d==NULL || key==NULL) + return def ; + + lc_key = strlwc(key); + sval = dictionary_get(d, lc_key, def); + return sval ; +} + +/*-------------------------------------------------------------------------*/ +/** + @brief Get the string associated to a key, convert to an int + @param d Dictionary to search + @param key Key string to look for + @param notfound Value to return in case of error + @return integer + + This function queries a dictionary for a key. A key as read from an + ini file is given as "section:key". If the key cannot be found, + the notfound value is returned. + + Supported values for integers include the usual C notation + so decimal, octal (starting with 0) and hexadecimal (starting with 0x) + are supported. Examples: + + "42" -> 42 + "042" -> 34 (octal -> decimal) + "0x42" -> 66 (hexa -> decimal) + + Warning: the conversion may overflow in various ways. Conversion is + totally outsourced to strtol(), see the associated man page for overflow + handling. + + Credits: Thanks to A. Becker for suggesting strtol() + */ +/*--------------------------------------------------------------------------*/ +int iniparser_getint(dictionary * d, const char * key, int notfound) +{ + char * str ; + + str = iniparser_getstring(d, key, INI_INVALID_KEY); + if (str==INI_INVALID_KEY) return notfound ; + return (int)strtol(str, NULL, 0); +} + +/*-------------------------------------------------------------------------*/ +/** + @brief Get the string associated to a key, convert to a double + @param d Dictionary to search + @param key Key string to look for + @param notfound Value to return in case of error + @return double + + This function queries a dictionary for a key. A key as read from an + ini file is given as "section:key". If the key cannot be found, + the notfound value is returned. + */ +/*--------------------------------------------------------------------------*/ +double iniparser_getdouble(dictionary * d, char * key, double notfound) +{ + char * str ; + + str = iniparser_getstring(d, key, INI_INVALID_KEY); + if (str==INI_INVALID_KEY) return notfound ; + return atof(str); +} + +/*-------------------------------------------------------------------------*/ +/** + @brief Get the string associated to a key, convert to a boolean + @param d Dictionary to search + @param key Key string to look for + @param notfound Value to return in case of error + @return integer + + This function queries a dictionary for a key. A key as read from an + ini file is given as "section:key". If the key cannot be found, + the notfound value is returned. + + A true boolean is found if one of the following is matched: + + - A string starting with 'y' + - A string starting with 'Y' + - A string starting with 't' + - A string starting with 'T' + - A string starting with '1' + + A false boolean is found if one of the following is matched: + + - A string starting with 'n' + - A string starting with 'N' + - A string starting with 'f' + - A string starting with 'F' + - A string starting with '0' + + The notfound value returned if no boolean is identified, does not + necessarily have to be 0 or 1. + */ +/*--------------------------------------------------------------------------*/ +int iniparser_getboolean(dictionary * d, const char * key, int notfound) +{ + char * c ; + int ret ; + + c = iniparser_getstring(d, key, INI_INVALID_KEY); + if (c==INI_INVALID_KEY) return notfound ; + if (c[0]=='y' || c[0]=='Y' || c[0]=='1' || c[0]=='t' || c[0]=='T') { + ret = 1 ; + } else if (c[0]=='n' || c[0]=='N' || c[0]=='0' || c[0]=='f' || c[0]=='F') { + ret = 0 ; + } else { + ret = notfound ; + } + return ret; +} + +/*-------------------------------------------------------------------------*/ +/** + @brief Finds out if a given entry exists in a dictionary + @param ini Dictionary to search + @param entry Name of the entry to look for + @return integer 1 if entry exists, 0 otherwise + + Finds out if a given entry exists in the dictionary. Since sections + are stored as keys with NULL associated values, this is the only way + of querying for the presence of sections in a dictionary. + */ +/*--------------------------------------------------------------------------*/ +int iniparser_find_entry( + dictionary * ini, + char * entry +) +{ + int found=0 ; + if (iniparser_getstring(ini, entry, INI_INVALID_KEY)!=INI_INVALID_KEY) { + found = 1 ; + } + return found ; +} + +/*-------------------------------------------------------------------------*/ +/** + @brief Set an entry in a dictionary. + @param ini Dictionary to modify. + @param entry Entry to modify (entry name) + @param val New value to associate to the entry. + @return int 0 if Ok, -1 otherwise. + + If the given entry can be found in the dictionary, it is modified to + contain the provided value. If it cannot be found, -1 is returned. + It is Ok to set val to NULL. + */ +/*--------------------------------------------------------------------------*/ +int iniparser_set(dictionary * ini, char * entry, char * val) +{ + return dictionary_set(ini, strlwc(entry), val) ; +} + +/*-------------------------------------------------------------------------*/ +/** + @brief Delete an entry in a dictionary + @param ini Dictionary to modify + @param entry Entry to delete (entry name) + @return void + + If the given entry can be found, it is deleted from the dictionary. + */ +/*--------------------------------------------------------------------------*/ +void iniparser_unset(dictionary * ini, char * entry) +{ + dictionary_unset(ini, strlwc(entry)); +} + +/*-------------------------------------------------------------------------*/ +/** + @brief Load a single line from an INI file + @param input_line Input line, may be concatenated multi-line input + @param section Output space to store section + @param key Output space to store key + @param value Output space to store value + @return line_status value + */ +/*--------------------------------------------------------------------------*/ +static line_status iniparser_line( + char * input_line, + char * section, + char * key, + char * value) +{ + line_status sta ; + char line[ASCIILINESZ+1]; + int len ; + + strcpy(line, strstrip(input_line)); + len = (int)strlen(line); + + sta = LINE_UNPROCESSED ; + if (len<1) { + /* Empty line */ + sta = LINE_EMPTY ; + } else if (line[0]=='#') { + /* Comment line */ + sta = LINE_COMMENT ; + } else if (line[0]=='[' && line[len-1]==']') { + /* Section name */ + sscanf(line, "[%[^]]", section); + strcpy(section, strstrip(section)); + strcpy(section, strlwc(section)); + sta = LINE_SECTION ; + } else if (sscanf (line, "%[^=] = \"%[^\"]\"", key, value) == 2 + || sscanf (line, "%[^=] = '%[^\']'", key, value) == 2 + || sscanf (line, "%[^=] = %[^;#]", key, value) == 2) { + /* Usual key=value, with or without comments */ + strcpy(key, strstrip(key)); + strcpy(key, strlwc(key)); + strcpy(value, strstrip(value)); + /* + * sscanf cannot handle '' or "" as empty values + * this is done here + */ + if (!strcmp(value, "\"\"") || (!strcmp(value, "''"))) { + value[0]=0 ; + } + sta = LINE_VALUE ; + } else if (sscanf(line, "%[^=] = %[;#]", key, value)==2 + || sscanf(line, "%[^=] %[=]", key, value) == 2) { + /* + * Special cases: + * key= + * key=; + * key=# + */ + strcpy(key, strstrip(key)); + strcpy(key, strlwc(key)); + value[0]=0 ; + sta = LINE_VALUE ; + } else { + /* Generate syntax error */ + sta = LINE_ERROR ; + } + return sta ; +} + +/*-------------------------------------------------------------------------*/ +/** + @brief Parse an ini file and return an allocated dictionary object + @param in FILE* to read INI from + @return Pointer to newly allocated dictionary + + This is the parser for ini files. This function is called, providing + the name of the file to be read. It returns a dictionary object that + should not be accessed directly, but through accessor functions + instead. + + The returned dictionary must be freed using iniparser_freedict(). + */ +/*--------------------------------------------------------------------------*/ +dictionary * iniparser_loadfile(FILE * in) +{ + char line [ASCIILINESZ+1] ; + char section [ASCIILINESZ+1] ; + char key [ASCIILINESZ+1] ; + char tmp [ASCIILINESZ+1] ; + char val [ASCIILINESZ+1] ; + + int last=0 ; + int len ; + int lineno=0 ; + int errs=0; + + dictionary * dict ; + + if(in == NULL) { + return NULL ; + } + + dict = dictionary_new(0) ; + if (!dict) { + return NULL ; + } + + memset(line, 0, ASCIILINESZ); + memset(section, 0, ASCIILINESZ); + memset(key, 0, ASCIILINESZ); + memset(val, 0, ASCIILINESZ); + last=0 ; + + while (fgets(line+last, ASCIILINESZ-last, in)!=NULL) { + lineno++ ; + len = (int)strlen(line)-1; + /* Safety check against buffer overflows */ + if (line[len]!='\n') { + fprintf(stderr, + "iniparser: input line too long in file (%d)\n", + lineno); + dictionary_del(dict); + return NULL ; + } + /* Get rid of \n and spaces at end of line */ + while ((len>=0) && + ((line[len]=='\n') || (isspace(line[len])))) { + line[len]=0 ; + len-- ; + } + /* Detect multi-line */ + if (line[len]=='\\') { + /* Multi-line value */ + last=len ; + continue ; + } else { + last=0 ; + } + switch (iniparser_line(line, section, key, val)) { + case LINE_EMPTY: + case LINE_COMMENT: + break ; + + case LINE_SECTION: + errs = dictionary_set(dict, section, NULL); + break ; + + case LINE_VALUE: + sprintf(tmp, "%s:%s", section, key); + errs = dictionary_set(dict, tmp, val) ; + break ; + + case LINE_ERROR: + fprintf(stderr, "iniparser: syntax error in file (%d):\n", + lineno); + fprintf(stderr, "-> %s\n", line); + errs++ ; + break; + + default: + break ; + } + memset(line, 0, ASCIILINESZ); + last=0; + if (errs<0) { + fprintf(stderr, "iniparser: memory allocation failure\n"); + break ; + } + } + if (errs) { + dictionary_del(dict); + dict = NULL ; + } + return dict ; +} + +/*-------------------------------------------------------------------------*/ +/** + @brief Parse an ini file and return an allocated dictionary object + @param ininame Name of the ini file to read. + @return Pointer to newly allocated dictionary + + This is the parser for ini files. This function is called, providing + the name of the file to be read. It returns a dictionary object that + should not be accessed directly, but through accessor functions + instead. + + The returned dictionary must be freed using iniparser_freedict(). + */ +/*--------------------------------------------------------------------------*/ +dictionary * iniparser_load(const char * ininame) +{ + FILE * in; + dictionary * dict; + + if ((in=fopen(ininame, "r"))==NULL) { + fprintf(stderr, "iniparser: cannot open %s\n", ininame); + return NULL ; + } + + dict = iniparser_loadfile(in); + fclose(in); + + return dict ; +} + +/*-------------------------------------------------------------------------*/ +/** + @brief Free all memory associated to an ini dictionary + @param d Dictionary to free + @return void + + Free all memory associated to an ini dictionary. + It is mandatory to call this function before the dictionary object + gets out of the current context. + */ +/*--------------------------------------------------------------------------*/ +void iniparser_freedict(dictionary * d) +{ + dictionary_del(d); +} + +/* vim: set ts=4 et sw=4 tw=75 */ diff --git a/pred_src/ini/iniparser.h b/pred_src/ini/iniparser.h new file mode 100644 index 0000000..757deb6 --- /dev/null +++ b/pred_src/ini/iniparser.h @@ -0,0 +1,296 @@ + +/*-------------------------------------------------------------------------*/ +/** + @file iniparser.h + @author N. Devillard + @date Sep 2007 + @version 3.0 + @brief Parser for ini files. +*/ +/*--------------------------------------------------------------------------*/ + +/* + $Id: iniparser.h,v 1.24 2007-11-23 21:38:19 ndevilla Exp $ + $Revision: 1.24 $ +*/ + +#ifndef _INIPARSER_H_ +#define _INIPARSER_H_ + +/*--------------------------------------------------------------------------- + Includes + ---------------------------------------------------------------------------*/ + +#include +#include +#include + +/* + * The following #include is necessary on many Unixes but not Linux. + * It is not needed for Windows platforms. + * Uncomment it if needed. + */ +/* #include */ + +#include "dictionary.h" + +/*--------------------------------------------------------------------------- + Macros + ---------------------------------------------------------------------------*/ +/** For backwards compatibility only */ +#define iniparser_getstr(d, k) iniparser_getstring(d, k, NULL) +#define iniparser_setstr iniparser_setstring + +/*-------------------------------------------------------------------------*/ +/** + @brief Get number of sections in a dictionary + @param d Dictionary to examine + @return int Number of sections found in dictionary + + This function returns the number of sections found in a dictionary. + The test to recognize sections is done on the string stored in the + dictionary: a section name is given as "section" whereas a key is + stored as "section:key", thus the test looks for entries that do not + contain a colon. + + This clearly fails in the case a section name contains a colon, but + this should simply be avoided. + + This function returns -1 in case of error. + */ +/*--------------------------------------------------------------------------*/ + +int iniparser_getnsec(dictionary * d); + + +/*-------------------------------------------------------------------------*/ +/** + @brief Get name for section n in a dictionary. + @param d Dictionary to examine + @param n Section number (from 0 to nsec-1). + @return Pointer to char string + + This function locates the n-th section in a dictionary and returns + its name as a pointer to a string statically allocated inside the + dictionary. Do not free or modify the returned string! + + This function returns NULL in case of error. + */ +/*--------------------------------------------------------------------------*/ + +char * iniparser_getsecname(dictionary * d, int n); + + +/*-------------------------------------------------------------------------*/ +/** + @brief Save a dictionary to a loadable ini file + @param d Dictionary to dump + @param f Opened file pointer to dump to + @return void + + This function dumps a given dictionary into a loadable ini file. + It is Ok to specify @c stderr or @c stdout as output files. + */ +/*--------------------------------------------------------------------------*/ + +void iniparser_dump_ini(dictionary * d, FILE * f); + +/*-------------------------------------------------------------------------*/ +/** + @brief Dump a dictionary to an opened file pointer. + @param d Dictionary to dump. + @param f Opened file pointer to dump to. + @return void + + This function prints out the contents of a dictionary, one element by + line, onto the provided file pointer. It is OK to specify @c stderr + or @c stdout as output files. This function is meant for debugging + purposes mostly. + */ +/*--------------------------------------------------------------------------*/ +void iniparser_dump(dictionary * d, FILE * f); + +/*-------------------------------------------------------------------------*/ +/** + @brief Get the string associated to a key + @param d Dictionary to search + @param key Key string to look for + @param def Default value to return if key not found. + @return pointer to statically allocated character string + + This function queries a dictionary for a key. A key as read from an + ini file is given as "section:key". If the key cannot be found, + the pointer passed as 'def' is returned. + The returned char pointer is pointing to a string allocated in + the dictionary, do not free or modify it. + */ +/*--------------------------------------------------------------------------*/ +char * iniparser_getstring(dictionary * d, const char * key, char * def); + +/*-------------------------------------------------------------------------*/ +/** + @brief Get the string associated to a key, convert to an int + @param d Dictionary to search + @param key Key string to look for + @param notfound Value to return in case of error + @return integer + + This function queries a dictionary for a key. A key as read from an + ini file is given as "section:key". If the key cannot be found, + the notfound value is returned. + + Supported values for integers include the usual C notation + so decimal, octal (starting with 0) and hexadecimal (starting with 0x) + are supported. Examples: + + - "42" -> 42 + - "042" -> 34 (octal -> decimal) + - "0x42" -> 66 (hexa -> decimal) + + Warning: the conversion may overflow in various ways. Conversion is + totally outsourced to strtol(), see the associated man page for overflow + handling. + + Credits: Thanks to A. Becker for suggesting strtol() + */ +/*--------------------------------------------------------------------------*/ +int iniparser_getint(dictionary * d, const char * key, int notfound); + +/*-------------------------------------------------------------------------*/ +/** + @brief Get the string associated to a key, convert to a double + @param d Dictionary to search + @param key Key string to look for + @param notfound Value to return in case of error + @return double + + This function queries a dictionary for a key. A key as read from an + ini file is given as "section:key". If the key cannot be found, + the notfound value is returned. + */ +/*--------------------------------------------------------------------------*/ +double iniparser_getdouble(dictionary * d, char * key, double notfound); + +/*-------------------------------------------------------------------------*/ +/** + @brief Get the string associated to a key, convert to a boolean + @param d Dictionary to search + @param key Key string to look for + @param notfound Value to return in case of error + @return integer + + This function queries a dictionary for a key. A key as read from an + ini file is given as "section:key". If the key cannot be found, + the notfound value is returned. + + A true boolean is found if one of the following is matched: + + - A string starting with 'y' + - A string starting with 'Y' + - A string starting with 't' + - A string starting with 'T' + - A string starting with '1' + + A false boolean is found if one of the following is matched: + + - A string starting with 'n' + - A string starting with 'N' + - A string starting with 'f' + - A string starting with 'F' + - A string starting with '0' + + The notfound value returned if no boolean is identified, does not + necessarily have to be 0 or 1. + */ +/*--------------------------------------------------------------------------*/ +int iniparser_getboolean(dictionary * d, const char * key, int notfound); + + +/*-------------------------------------------------------------------------*/ +/** + @brief Set an entry in a dictionary. + @param ini Dictionary to modify. + @param entry Entry to modify (entry name) + @param val New value to associate to the entry. + @return int 0 if Ok, -1 otherwise. + + If the given entry can be found in the dictionary, it is modified to + contain the provided value. If it cannot be found, -1 is returned. + It is Ok to set val to NULL. + */ +/*--------------------------------------------------------------------------*/ +int iniparser_setstring(dictionary * ini, char * entry, char * val); + + +/*-------------------------------------------------------------------------*/ +/** + @brief Delete an entry in a dictionary + @param ini Dictionary to modify + @param entry Entry to delete (entry name) + @return void + + If the given entry can be found, it is deleted from the dictionary. + */ +/*--------------------------------------------------------------------------*/ +void iniparser_unset(dictionary * ini, char * entry); + +/*-------------------------------------------------------------------------*/ +/** + @brief Finds out if a given entry exists in a dictionary + @param ini Dictionary to search + @param entry Name of the entry to look for + @return integer 1 if entry exists, 0 otherwise + + Finds out if a given entry exists in the dictionary. Since sections + are stored as keys with NULL associated values, this is the only way + of querying for the presence of sections in a dictionary. + */ +/*--------------------------------------------------------------------------*/ +int iniparser_find_entry(dictionary * ini, char * entry) ; + +/*-------------------------------------------------------------------------*/ +/** + @brief Parse an ini file and return an allocated dictionary object + @param ininame Name of the ini file to read. + @return Pointer to newly allocated dictionary + + This is the parser for ini files. This function is called, providing + the name of the file to be read. It returns a dictionary object that + should not be accessed directly, but through accessor functions + instead. + + The returned dictionary must be freed using iniparser_freedict(). + */ +/*--------------------------------------------------------------------------*/ +dictionary * iniparser_load(const char * ininame); + +/*-------------------------------------------------------------------------*/ +/** + @brief Parse an ini file and return an allocated dictionary object + @param file FILE* associated with file to read + @return Pointer to newly allocated dictionary + + This is the parser for ini files. This function is called, providing + the name of the file to be read. It returns a dictionary object that + should not be accessed directly, but through accessor functions + instead. + + The returned dictionary must be freed using iniparser_freedict(). + */ +/*--------------------------------------------------------------------------*/ +dictionary * iniparser_loadfile(FILE * file); + +/*-------------------------------------------------------------------------*/ +/** + @brief Free all memory associated to an ini dictionary + @param d Dictionary to free + @return void + + Free all memory associated to an ini dictionary. + It is mandatory to call this function before the dictionary object + gets out of the current context. + */ +/*--------------------------------------------------------------------------*/ +void iniparser_freedict(dictionary * d); + +#endif diff --git a/pred_src/pred b/pred_src/pred new file mode 100755 index 0000000..12f253f Binary files /dev/null and b/pred_src/pred differ diff --git a/pred_src/pred.c b/pred_src/pred.c new file mode 100644 index 0000000..b67f5ee --- /dev/null +++ b/pred_src/pred.c @@ -0,0 +1,363 @@ +// -------------------------------------------------------------- +// CU Spaceflight Landing Prediction +// Copyright (c) CU Spaceflight 2009, All Right Reserved +// +// Written by Rob Anderson +// Modified by Fergus Noble +// +// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY +// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// -------------------------------------------------------------- + +#include +#include +#include +#include +#include + +#include "ini/iniparser.h" +#include "util/gopt.h" +#include "wind/wind_file_cache.h" + +#include "run_model.h" +#include "pred.h" +#include "altitude.h" + +FILE* output; +FILE* kml_file; +const char* data_dir; +int verbosity; + +int main(int argc, const char *argv[]) { + + const char* argument; + + long int initial_timestamp; + float initial_lat, initial_lng, initial_alt; + float burst_alt, ascent_rate, drag_coeff, rmswinderror; + int descent_mode; + int scenario_idx, n_scenarios; + char* endptr; // used to check for errors on strtod calls + + wind_file_cache_t* file_cache; + dictionary* scenario = NULL; + + // configure command-line options parsing + void *options = gopt_sort(&argc, argv, gopt_start( + gopt_option('h', 0, gopt_shorts('h', '?'), gopt_longs("help")), + gopt_option('z', 0, gopt_shorts(0), gopt_longs("version")), + gopt_option('v', GOPT_REPEAT, gopt_shorts('v'), gopt_longs("verbose")), + gopt_option('o', GOPT_ARG, gopt_shorts('o'), gopt_longs("output")), + gopt_option('k', GOPT_ARG, gopt_shorts('k'), gopt_longs("kml")), + gopt_option('t', GOPT_ARG, gopt_shorts('t'), gopt_longs("start_time")), + gopt_option('i', GOPT_ARG, gopt_shorts('i'), gopt_longs("data_dir")), + gopt_option('d', 0, gopt_shorts('d'), gopt_longs("descending")), + gopt_option('e', GOPT_ARG, gopt_shorts('e'), gopt_longs("wind_error")) + )); + + if (gopt(options, 'h')) { + // Help! + // Print usage information + printf("Usage: %s [options] [scenario files]\n", argv[0]); + printf("Options:\n\n"); + printf(" -h --help Display this information.\n"); + printf(" --version Display version information.\n"); + printf(" -v --verbose Display more information while running,\n"); + printf(" Use -vv, -vvv etc. for even more verbose output.\n"); + printf(" -t --start_time Start time of model, defaults to current time.\n"); + printf(" Should be a UNIX standard format timestamp.\n"); + printf(" -o --output Output file for CSV data, defaults to stdout. Overrides scenario.\n"); + printf(" -k --kml Output KML file.\n"); + printf(" -d --descending We are in the descent phase of the flight, i.e. after\n"); + printf(" burst or cutdown. burst_alt and ascent_rate ignored.\n"); + printf(" -i --data_dir Input directory for wind data, defaults to current dir.\n\n"); + printf(" -e --wind_error RMS windspeed error (m/s).\n"); + printf("The scenario file is an INI-like file giving the launch scenario. If it is\n"); + printf("omitted, the scenario is read from standard input.\n"); + exit(0); + } + + if (gopt(options, 'z')) { + // Version information + printf("Landing Prediction version: %s\nCopyright (c) CU Spaceflight 2009\n", VERSION); + exit(0); + } + + verbosity = gopt(options, 'v'); + + if (gopt(options, 'd')) + descent_mode = DESCENT_MODE_DESCENDING; + else + descent_mode = DESCENT_MODE_NORMAL; + + if (gopt_arg(options, 'k', &argument) && strcmp(argument, "-")) { + kml_file = fopen(argument, "wb"); + if (!kml_file) { + fprintf(stderr, "ERROR: %s: could not open KML file for output\n", argument); + exit(1); + } + } + else + kml_file = NULL; + + if (gopt_arg(options, 't', &argument) && strcmp(argument, "-")) { + initial_timestamp = strtol(argument, &endptr, 0); + if (endptr == argument) { + fprintf(stderr, "ERROR: %s: invalid start timestamp\n", argument); + exit(1); + } + } else { + initial_timestamp = time(NULL); + } + + if (!(gopt_arg(options, 'i', &data_dir) && strcmp(data_dir, "-"))) + data_dir = "./"; + + + // populate wind data file cache + file_cache = wind_file_cache_new(data_dir); + + // read in flight parameters + n_scenarios = argc - 1; + if(n_scenarios == 0) { + // we'll parse from std in + n_scenarios = 1; + } + + for(scenario_idx = 0; scenario_idx < n_scenarios; ++scenario_idx) { + char* scenario_output = NULL; + + if(argc > scenario_idx+1) { + scenario = iniparser_load(argv[scenario_idx+1]); + } else { + scenario = iniparser_loadfile(stdin); + } + + if(!scenario) { + fprintf(stderr, "ERROR: could not parse scanario file.\n"); + exit(1); + } + + if(verbosity > 1) { + fprintf(stderr, "INFO: Parsed scenario file:\n"); + iniparser_dump_ini(scenario, stderr); + } + + scenario_output = iniparser_getstring(scenario, "output:filename", NULL); + + if (gopt_arg(options, 'o', &argument) && strcmp(argument, "-")) { + if(verbosity > 0) { + fprintf(stderr, "INFO: Writing output to file specified on command line: %s\n", argument); + } + output = fopen(argument, "wb"); + if (!output) { + fprintf(stderr, "ERROR: %s: could not open CSV file for output\n", argument); + exit(1); + } + } else if (scenario_output != NULL) { + if(verbosity > 0) { + fprintf(stderr, "INFO: Writing output to file specified in scenario: %s\n", scenario_output); + } + output = fopen(scenario_output, "wb"); + if (!output) { + fprintf(stderr, "ERROR: %s: could not open CSV file for output\n", scenario_output); + exit(1); + } + } else { + if(verbosity > 0) { + fprintf(stderr, "INFO: Writing output to stdout.\n"); + } + output = stdout; + } + + // write KML header + if (kml_file) + start_kml(); + + // The observant amongst you will notice that there are default values for + // *all* keys. This information should not be spread around too well. + // Unfortunately, this means we lack some error checking. + + initial_lat = iniparser_getdouble(scenario, "launch-site:latitude", 0.0); + initial_lng = iniparser_getdouble(scenario, "launch-site:longitude", 0.0); + initial_alt = iniparser_getdouble(scenario, "launch-site:altitude", 0.0); + + ascent_rate = iniparser_getdouble(scenario, "altitude-model:ascent-rate", 1.0); + + // The 1.1045 comes from a magic constant buried in + // ~cuspaceflight/public_html/predict/index.php. + drag_coeff = iniparser_getdouble(scenario, "altitude-model:descent-rate", 1.0) * 1.1045; + + burst_alt = iniparser_getdouble(scenario, "altitude-model:burst-altitude", 1.0); + + rmswinderror = iniparser_getdouble(scenario, "atmosphere:wind-error", 0.0); + if(gopt_arg(options, 'e', &argument) && strcmp(argument, "-")) { + rmswinderror = strtod(argument, &endptr); + if (endptr == argument) { + fprintf(stderr, "ERROR: %s: invalid RMS wind speed error\n", argument); + exit(1); + } + } + + { + int year, month, day, hour, minute, second; + year = iniparser_getint(scenario, "launch-time:year", -1); + month = iniparser_getint(scenario, "launch-time:month", -1); + day = iniparser_getint(scenario, "launch-time:day", -1); + hour = iniparser_getint(scenario, "launch-time:hour", -1); + minute = iniparser_getint(scenario, "launch-time:minute", -1); + second = iniparser_getint(scenario, "launch-time:second", -1); + + if((year >= 0) && (month >= 0) && (day >= 0) && (hour >= 0) + && (minute >= 0) && (second >= 0)) + { + struct tm timeval = { 0 }; + time_t scenario_launch_time = -1; + + if(verbosity > 0) { + fprintf(stderr, "INFO: Using launch time from scenario: " + "%i/%i/%i %i:%i:%i\n", + year, month, day, hour, minute, second); + } + + timeval.tm_sec = second; + timeval.tm_min = minute; + timeval.tm_hour = hour; + timeval.tm_mday = day; /* 1 - 31 */ + timeval.tm_mon = month - 1; /* 0 - 11 */ + timeval.tm_year = year - 1900; /* fuck you Millenium Bug! */ + +#ifndef _BSD_SOURCE +# warning This version of mktime does not allow explicit setting of timezone. +#else + timeval.tm_zone = "UTC"; +#endif + + scenario_launch_time = mktime(&timeval); + if(scenario_launch_time <= 0) { + fprintf(stderr, "WARN: Launch time in scenario is invalid, reverting to " + "default timestamp.\n"); + } else { + initial_timestamp = scenario_launch_time; + } + } + } + + if(verbosity > 0) { + fprintf(stderr, "INFO: Scenario loaded:\n"); + fprintf(stderr, " - Initial latitude : %lf deg N\n", initial_lat); + fprintf(stderr, " - Initial longitude : %lf deg E\n", initial_lng); + fprintf(stderr, " - Initial altitude : %lf m above sea level\n", initial_alt); + fprintf(stderr, " - Initial timestamp : %li\n", initial_timestamp); + fprintf(stderr, " - Drag coeff. : %lf\n", drag_coeff); + if(!descent_mode) { + fprintf(stderr, " - Ascent rate : %lf m/s\n", ascent_rate); + fprintf(stderr, " - Burst alt. : %lf m\n", burst_alt); + } + fprintf(stderr, " - Windspeed err. : %f m/s\n", rmswinderror); + } + + { + // do the actual stuff!! + altitude_model_t* alt_model = altitude_model_new(descent_mode, burst_alt, + ascent_rate, drag_coeff); + if(!alt_model) { + fprintf(stderr, "ERROR: error initialising altitude profile\n"); + exit(1); + } + + if (!run_model(file_cache, alt_model, + initial_lat, initial_lng, initial_alt, initial_timestamp, + rmswinderror)) { + fprintf(stderr, "ERROR: error during model run!\n"); + exit(1); + } + + altitude_model_free(alt_model); + } + + // release the scenario + iniparser_freedict(scenario); + + // write footer to KML and close output files + if (kml_file) { + finish_kml(); + fclose(kml_file); + } + + if (output != stdout) { + fclose(output); + } + } + + // release gopt data, + gopt_free(options); + + // release the file cache resources. + wind_file_cache_free(file_cache); + + return 0; +} + +void write_position(float lat, float lng, float alt, int timestamp) { + if (kml_file) { + fprintf(kml_file, "%g,%g,%g\n", lng, lat, alt); + if (ferror(kml_file)) { + fprintf(stderr, "ERROR: error writing to KML file\n"); + exit(1); + } + } + + fprintf(output, "%d,%g,%g,%g\n", timestamp, lat, lng, alt); + if (ferror(output)) { + fprintf(stderr, "ERROR: error writing to CSV file\n"); + exit(1); + } +} + +void start_kml() { + FILE* kml_header; + char c; + + kml_header = fopen("kml_header", "r"); + + while (!feof(kml_header)) { + c = fgetc(kml_header); + if (ferror(kml_header)) { + fprintf(stderr, "ERROR: error reading KML header file\n"); + exit(1); + } + if (!feof(kml_header)) fputc(c, kml_file); + if (ferror(kml_file)) { + fprintf(stderr, "ERROR: error writing header to KML file\n"); + exit(1); + } + } + + fclose(kml_header); +} + +void finish_kml() { + FILE* kml_footer; + char c; + + kml_footer = fopen("kml_footer", "r"); + + while (!feof(kml_footer)) { + c = fgetc(kml_footer); + if (ferror(kml_footer)) { + fprintf(stderr, "ERROR: error reading KML footer file\n"); + exit(1); + } + if (!feof(kml_footer)) fputc(c, kml_file); + if (ferror(kml_file)) { + fprintf(stderr, "ERROR: error writing footer to KML file\n"); + exit(1); + } + } + + fclose(kml_footer); +} + diff --git a/pred_src/pred.h b/pred_src/pred.h new file mode 100644 index 0000000..fc49c47 --- /dev/null +++ b/pred_src/pred.h @@ -0,0 +1,28 @@ +// -------------------------------------------------------------- +// CU Spaceflight Landing Prediction +// Copyright (c) CU Spaceflight 2009, All Right Reserved +// +// Written by Rob Anderson +// Modified by Fergus Noble +// +// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY +// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// -------------------------------------------------------------- + +#ifndef __PRED_H__ +#define __PRED_H__ + +#define VERSION "0.0.1" + +// write a position entry into the output files +void write_position(float lat, float lng, float alt, int timestamp); + +// start and finish KML files, basically just write header and footer in +void start_kml(); +void finish_kml(); + +#endif // __PRED_H__ + + diff --git a/pred_src/run_model.c b/pred_src/run_model.c new file mode 100644 index 0000000..8f945be --- /dev/null +++ b/pred_src/run_model.c @@ -0,0 +1,239 @@ +// -------------------------------------------------------------- +// CU Spaceflight Landing Prediction +// Copyright (c) CU Spaceflight 2009, All Right Reserved +// +// Written by Rob Anderson +// Modified by Fergus Noble +// +// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY +// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// -------------------------------------------------------------- + +#include +#include +#include +#include + +#include "wind/wind_file.h" +#include "util/random.h" +#include "run_model.h" +#include "pred.h" +#include "altitude.h" + +extern int verbosity; + +#define RADIUS_OF_EARTH 6371009.f + +typedef struct model_state_s model_state_t; +struct model_state_s +{ + float lat; + float lng; + float alt; + altitude_model_t *alt_model; + double loglik; +}; + +// Get the distance (in metres) of one degree of latitude and one degree of +// longitude. This varys with height (not much grant you). +static void +_get_frame(float lat, float lng, float alt, + float *d_dlat, float *d_dlng) +{ + float theta, r; + + theta = 2.f * M_PI * (90.f - lat) / 360.f; + r = RADIUS_OF_EARTH + alt; + + // See the differentiation section of + // http://en.wikipedia.org/wiki/Spherical_coordinate_system + + // d/dv = d/dlat = -d/dtheta + *d_dlat = (2.f * M_PI) * r / 360.f; + + // d/du = d/dlong = d/dphi + *d_dlng = (2.f * M_PI) * r * sinf(theta) / 360.f; +} + +static int +_advance_one_timestep(wind_file_cache_t* cache, + unsigned long delta_t, + unsigned long timestamp, unsigned long initial_timestamp, + unsigned int n_states, model_state_t* states, + float rmserror) +{ + unsigned int i; + + for(i=0; ialt_model, + timestamp - initial_timestamp, &state->alt)) + return 0; + + if(!get_wind(cache, state->lat, state->lng, state->alt, timestamp, + &wind_v, &wind_u, &wind_var)) { + fprintf(stderr, "ERROR: error getting wind data\n"); + return 0; + } + + _get_frame(state->lat, state->lng, state->alt, &ddlat, &ddlng); + + // NOTE: it this really the right thing to be doing? - think about what + // happens near the poles + + wind_var += rmserror * rmserror; + + assert(wind_var >= 0.f); + + //fprintf(stderr, "U: %f +/- %f, V: %f +/- %f\n", + // wind_u, sqrtf(wind_u_var), + // wind_v, sqrtf(wind_v_var)); + + u_samp = random_sample_normal(wind_u, wind_var, &u_lik); + v_samp = random_sample_normal(wind_v, wind_var, &v_lik); + + //u_samp = wind_u; + //v_samp = wind_v; + + state->lat += v_samp * delta_t / ddlat; + state->lng += u_samp * delta_t / ddlng; + + state->loglik += (double)(u_lik + v_lik); + } + + return 1; +} + +static int _state_compare_rev(const void* a, const void *b) +{ + model_state_t* sa = (model_state_t*)a; + model_state_t* sb = (model_state_t*)b; + + // this returns a value s.t. the states will be sorted so that + // the maximum likelihood state is at position 0. + return sb->loglik - sa->loglik; +} + +int run_model(wind_file_cache_t* cache, altitude_model_t* alt_model, + float initial_lat, float initial_lng, float initial_alt, + long int initial_timestamp, float rmswinderror) +{ + model_state_t* states; + const unsigned int n_states = 1; + unsigned int i; + + states = (model_state_t*) malloc( sizeof(model_state_t) * n_states ); + + for(i=0; ialt = initial_alt; + state->lat = initial_lat; + state->lng = initial_lng; + state->alt_model = alt_model; + state->loglik = 0.f; + } + + long int timestamp = initial_timestamp; + + int log_counter = 0; // only write position to output files every LOG_DECIMATE timesteps + + while(_advance_one_timestep(cache, TIMESTEP, timestamp, initial_timestamp, + n_states, states, rmswinderror)) + { + // Sort the array of models in order of log likelihood. + qsort(states, n_states, sizeof(model_state_t), _state_compare_rev); + + // write the maximum likelihood state out. + if (log_counter == LOG_DECIMATE) { + write_position(states[0].lat, states[0].lng, states[0].alt, timestamp); + log_counter = 0; + } + + log_counter++; + timestamp += TIMESTEP; + } + + for(i=0; ilat, state->lng, state->alt, timestamp); + } + + fprintf(stderr, "INFO: Final maximum log lik: %f (=%f)\n", + states[0].loglik, exp(states[0].loglik)); + + free(states); + + return 1; +} + +int get_wind(wind_file_cache_t* cache, float lat, float lng, float alt, long int timestamp, + float* wind_v, float* wind_u, float *wind_var) { + int i; + float lambda, wu_l, wv_l, wu_h, wv_h; + float wuvar_l, wvvar_l, wuvar_h, wvvar_h; + wind_file_cache_entry_t* found_entries[] = { NULL, NULL }; + wind_file_t* found_files[] = { NULL, NULL }; + unsigned int earlier_ts, later_ts; + + // look for a wind file which matches this latitude and longitude... + wind_file_cache_find_entry(cache, lat, lng, timestamp, + &(found_entries[0]), &(found_entries[1])); + + if(!found_entries[0] || !found_entries[1]) { + fprintf(stderr, "ERROR: Could not locate appropriate wind data tile for time.\n"); + return 0; + } + + if(!wind_file_cache_entry_contains_point(found_entries[0], lat, lng) || + !wind_file_cache_entry_contains_point(found_entries[1], lat, lng)) + { + fprintf(stderr, "ERROR: Could not locate appropriate wind data tile for location " + "lat=%f, lon=%f.\n", lat, lng); + return 0; + } + + // Look in the cache for the files we need. + for(i=0; i<2; ++i) + { + found_files[i] = wind_file_cache_entry_file(found_entries[i]); + } + + earlier_ts = wind_file_cache_entry_timestamp(found_entries[0]); + later_ts = wind_file_cache_entry_timestamp(found_entries[1]); + + if(earlier_ts == later_ts) + { + fprintf(stderr, "WARN: Do not have two data files around current time. " + "Expect the results to be wrong!\n"); + } + + if(earlier_ts != later_ts) + lambda = ((float)timestamp - (float)earlier_ts) / + ((float)later_ts - (float)earlier_ts); + else + lambda = 0.5f; + + wind_file_get_wind(found_files[0], lat, lng, alt, &wu_l, &wv_l, &wuvar_l, &wvvar_l); + wind_file_get_wind(found_files[1], lat, lng, alt, &wu_h, &wv_h, &wuvar_h, &wvvar_h); + + *wind_u = lambda * wu_h + (1.f-lambda) * wu_l; + *wind_v = lambda * wv_h + (1.f-lambda) * wv_l; + + // flatten the u and v variances into a single mean variance for the + // magnitude. + *wind_var = 0.5f * (wuvar_h + wuvar_l + wvvar_h + wvvar_l); + + return 1; +} + +// vim:sw=4:ts=4:et:cindent diff --git a/pred_src/run_model.h b/pred_src/run_model.h new file mode 100644 index 0000000..c3d575f --- /dev/null +++ b/pred_src/run_model.h @@ -0,0 +1,40 @@ +// -------------------------------------------------------------- +// CU Spaceflight Landing Prediction +// Copyright (c) CU Spaceflight 2009, All Right Reserved +// +// Written by Rob Anderson +// Modified by Fergus Noble +// +// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY +// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// -------------------------------------------------------------- + +#ifndef __RUN_MODEL_H__ +#define __RUN_MODEL_H__ + +#include "wind/wind_file_cache.h" +#include "altitude.h" + +// run the model +int run_model(wind_file_cache_t* cache, altitude_model_t* alt_model, + float initial_lat, float initial_lng, float initial_alt, + long int initial_timestamp, float rmswinderror); + +#define TIMESTEP 1 // in seconds +#define LOG_DECIMATE 50 // write entry to output files every x timesteps + +#define METRES_TO_DEGREES 0.00000899289281755 // one metre corresponds to this many degrees latitude +#define DEGREES_TO_METRES 111198.92345 // one degree latitude corresponds to this many metres +#define DEGREES_TO_RADIANS 0.0174532925 // 1 degree is this many radians + +// get the wind values in the u and v directions at a point in space and time from the dataset data +// we interpolate lat, lng, alt and time. The GRIB data only contains pressure levels so we first +// determine which pressure levels straddle to our desired altitude and then interpolate between them +int get_wind(wind_file_cache_t* cache, float lat, float lng, float alt, long int timestamp, float* wind_v, float* wind_u, float *wind_var); +// note: get_wind will likely call load_data and load a different tile into data, so just be careful that data could be pointing +// somewhere else after running get_wind + +#endif // __RUN_MODEL_H__ + diff --git a/pred_src/util/getdelim.c b/pred_src/util/getdelim.c new file mode 100644 index 0000000..c31b50b --- /dev/null +++ b/pred_src/util/getdelim.c @@ -0,0 +1,128 @@ +/* getdelim.c --- Implementation of replacement getdelim function. + Copyright (C) 1994, 1996, 1997, 1998, 2001, 2003, 2005 Free + Software Foundation, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* Ported from glibc by Simon Josefsson. */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "getdelim.h" + +#include +#include +#include + +#ifndef SIZE_MAX +# define SIZE_MAX ((size_t) -1) +#endif +#ifndef SSIZE_MAX +# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) +#endif +#if !HAVE_FLOCKFILE +# undef flockfile +# define flockfile(x) ((void) 0) +#endif +#if !HAVE_FUNLOCKFILE +# undef funlockfile +# define funlockfile(x) ((void) 0) +#endif + +/* Read up to (and including) a DELIMITER from FP into *LINEPTR (and + NUL-terminate it). *LINEPTR is a pointer returned from malloc (or + NULL), pointing to *N characters of space. It is realloc'ed as + necessary. Returns the number of characters read (not including + the null terminator), or -1 on error or EOF. */ + +ssize_t +getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp) +{ + ssize_t result; + size_t cur_len = 0; + + if (lineptr == NULL || n == NULL || fp == NULL) + { + errno = EINVAL; + return -1; + } + + flockfile (fp); + + if (*lineptr == NULL || *n == 0) + { + *n = 120; + *lineptr = (char *) malloc (*n); + if (*lineptr == NULL) + { + result = -1; + goto unlock_return; + } + } + + for (;;) + { + int i; + + i = getc (fp); + if (i == EOF) + { + result = -1; + break; + } + + /* Make enough space for len+1 (for final NUL) bytes. */ + if (cur_len + 1 >= *n) + { + size_t needed_max = + SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX; + size_t needed = 2 * *n + 1; /* Be generous. */ + char *new_lineptr; + + if (needed_max < needed) + needed = needed_max; + if (cur_len + 1 >= needed) + { + result = -1; + goto unlock_return; + } + + new_lineptr = (char *) realloc (*lineptr, needed); + if (new_lineptr == NULL) + { + result = -1; + goto unlock_return; + } + + *lineptr = new_lineptr; + *n = needed; + } + + (*lineptr)[cur_len] = i; + cur_len++; + + if (i == delimiter) + break; + } + (*lineptr)[cur_len] = '\0'; + result = cur_len ? cur_len : result; + + unlock_return: + funlockfile (fp); + return result; +} diff --git a/pred_src/util/getdelim.h b/pred_src/util/getdelim.h new file mode 100644 index 0000000..7caf11d --- /dev/null +++ b/pred_src/util/getdelim.h @@ -0,0 +1,28 @@ +/* getdelim.h --- Prototype for replacement getdelim function. + Copyright (C) 2005 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* Written by Simon Josefsson. */ + +/* Get size_t, FILE, ssize_t. And getdelim, if available. */ +# include +# include +# include + +#if !HAVE_DECL_GETDELIM +ssize_t getdelim (char **lineptr, size_t *n, int delimiter, FILE *stream); +#endif /* !HAVE_GETDELIM */ diff --git a/pred_src/util/getline.c b/pred_src/util/getline.c new file mode 100644 index 0000000..b561e58 --- /dev/null +++ b/pred_src/util/getline.c @@ -0,0 +1,32 @@ +/* getline.c --- Implementation of replacement getline function. + Copyright (C) 2005 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* Written by Simon Josefsson. */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "getdelim.h" +#include "getline.h" + +ssize_t +getline (char **lineptr, size_t *n, FILE *stream) +{ + return getdelim (lineptr, n, '\n', stream); +} diff --git a/pred_src/util/getline.h b/pred_src/util/getline.h new file mode 100644 index 0000000..22b71a0 --- /dev/null +++ b/pred_src/util/getline.h @@ -0,0 +1,28 @@ +/* getline.h --- Prototype for replacement getline function. + Copyright (C) 2005 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ + +/* Written by Simon Josefsson. */ + +/* Get size_t, FILE, ssize_t. And getline, if available. */ +# include +# include +# include + +#if !HAVE_DECL_GETLINE +ssize_t getline (char **lineptr, size_t *n, FILE *stream); +#endif /* !HAVE_GETLINE */ diff --git a/pred_src/util/gopt.c b/pred_src/util/gopt.c new file mode 100644 index 0000000..6b5a5e0 --- /dev/null +++ b/pred_src/util/gopt.c @@ -0,0 +1,268 @@ +/* gopt.c version 8.1: tom.viza@gmail.com PUBLIC DOMAIN 2003-8 */ +/* +I, Tom Vajzovic, am the author of this software and its documentation and +permanently abandon all copyright and other intellectual property rights in +them, including the right to be identified as the author. + +I am fairly certain that this software does what the documentation says it +does, but I cannot guarantee that it does, or that it does what you think it +should, and I cannot guarantee that it will not have undesirable side effects. + +You are free to use, modify and distribute this software as you please, but +you do so at your own risk. If you remove or hide this warning then you are +responsible for any problems encountered by people that you make the software +available to. + +Before modifying or distributing this software I ask that you would please +read http://www.purposeful.co.uk/tfl/ +*/ + +#include +#include +#include +#include "gopt.h" + +#ifdef USE_SYSEXITS +#include +#else +#define EX_OSERR EXIT_FAILURE +#define EX_USAGE EXIT_FAILURE +#endif + +struct opt_spec_s { + int key; + int flags; + const char *shorts; + const char* const *longs; +}; +typedef struct opt_spec_s opt_spec_t; + +struct opt_s { + int key; + const char *arg; +}; +typedef struct opt_s opt_t; + +void *gopt_sort( int *argc, const char **argv, const void *opt_specs ){ + void *opts; + {{{ + const char* const *arg_p= argv + 1; + size_t opt_count= 1; + for( ; *arg_p; ++arg_p ) { + if( '-' == (*arg_p)[0] && (*arg_p)[1] ) { + if( '-' == (*arg_p)[1] ) { + if( (*arg_p)[2] ) { + ++opt_count; + } else { + break; + } + } else { + const opt_spec_t *opt_spec_p= opt_specs; + for( ; opt_spec_p-> key; ++opt_spec_p ) + if( strchr( opt_spec_p-> shorts, (*arg_p)[1] )){ + opt_count+= opt_spec_p-> flags & GOPT_ARG ? 1 : strlen( (*arg_p) + 1 ); + break; + } + } + } + } + opts= malloc( opt_count * sizeof(opt_t) ); + }}} + { + const char **arg_p= argv + 1; + const char **next_operand= arg_p; + opt_t *next_option= opts; + + if( ! opts ){ + perror( argv[0] ); + exit( EX_OSERR ); + } + for( ; *arg_p; ++arg_p ) + if( '-' == (*arg_p)[0] && (*arg_p)[1] ) + if( '-' == (*arg_p)[1] ) + if( (*arg_p)[2] ) + {{{ + const opt_spec_t *opt_spec_p= opt_specs; + const char* const *longs= opt_spec_p-> longs; + next_option-> key= 0; + while( *longs ){ + const char *option_cp= (*arg_p) + 2; + const char *name_cp= *longs; + while( *option_cp && *option_cp == *name_cp ){ + ++option_cp; + ++name_cp; + } + if( '=' == *option_cp || !*option_cp ){ + if( *name_cp ){ + if( next_option-> key ){ + fprintf( stderr, "%s: --%.*s: abbreviated option is ambiguous\n", argv[0], (int)( option_cp -( (*arg_p) + 2 )), (*arg_p) + 2 ); + free( opts ); + exit( EX_USAGE ); + } + next_option-> key= opt_spec_p-> key; + } + else { + next_option-> key= opt_spec_p-> key; + goto found_long; + } + } + if( !*++longs ){ + ++opt_spec_p; + if( opt_spec_p-> key ) + longs= opt_spec_p-> longs; + } + } + if( ! next_option-> key ){ + fprintf( stderr, "%s: --%.*s: unknown option\n", argv[0], (int)strcspn( (*arg_p) + 2, "=" ), (*arg_p) + 2 ); + free( opts ); + exit( EX_USAGE ); + } + for( opt_spec_p= opt_specs; opt_spec_p-> key != next_option-> key; ++opt_spec_p ); + found_long: + + if( !( opt_spec_p-> flags & GOPT_REPEAT )){ + const opt_t *opt_p= opts; + for( ; opt_p != next_option; ++opt_p ) + if( opt_p-> key == opt_spec_p-> key ){ + fprintf( stderr, "%s: --%.*s: option may not be repeated (in any long or short form)\n", argv[0], (int)strcspn( (*arg_p) + 2, "=" ), (*arg_p) + 2 ); + free( opts ); + exit( EX_USAGE ); + } + } + if( opt_spec_p-> flags & GOPT_ARG ){ + next_option-> arg= strchr( (*arg_p) + 2, '=' ) + 1; + if( (char*)0 + 1 == next_option-> arg ){ + ++arg_p; + if( !*arg_p || ('-' == (*arg_p)[0] && (*arg_p)[1]) ){ + fprintf( stderr, "%s: --%s: option requires an option argument\n", argv[0], (*(arg_p-1)) + 2 ); + free( opts ); + exit( EX_USAGE ); + } + next_option-> arg= *arg_p; + } + } + else { + if( strchr( (*arg_p) + 2, '=' )){ + fprintf( stderr, "%s: --%.*s: option may not take an option argument\n", argv[0], (int)strcspn( (*arg_p) + 2, "=" ), (*arg_p) + 2 ); + free( opts ); + exit( EX_USAGE ); + } + next_option-> arg= NULL; + } + ++next_option; + }}} + else { + for( ++arg_p; *arg_p; ++arg_p ) + *next_operand++= *arg_p; + break; + } + else + {{{ + const char *short_opt= (*arg_p) + 1; + for( ;*short_opt; ++short_opt ){ + const opt_spec_t *opt_spec_p= opt_specs; + + for( ; opt_spec_p-> key; ++opt_spec_p ) + if( strchr( opt_spec_p-> shorts, *short_opt )){ + if( !( opt_spec_p-> flags & GOPT_REPEAT )){ + const opt_t *opt_p= opts; + for( ; opt_p != next_option; ++opt_p ) + if( opt_p-> key == opt_spec_p-> key ){ + fprintf( stderr, "%s: -%c: option may not be repeated (in any long or short form)\n", argv[0], *short_opt ); + free( opts ); + exit( EX_USAGE ); + } + } + next_option-> key= opt_spec_p-> key; + + if( opt_spec_p-> flags & GOPT_ARG ){ + if( short_opt[1] ) + next_option-> arg= short_opt + 1; + + else { + ++arg_p; + if( !*arg_p || ('-' == (*arg_p)[0] && (*arg_p)[1]) ){ + fprintf( stderr, "%s: -%c: option requires an option argument\n", argv[0], *short_opt ); + free( opts ); + exit( EX_USAGE ); + } + next_option-> arg= *arg_p; + } + ++next_option; + goto break_2; + } + next_option-> arg= NULL; + ++next_option; + goto continue_2; + } + fprintf( stderr, "%s: -%c: unknown option\n", argv[0], *short_opt ); + free( opts ); + exit( EX_USAGE ); + continue_2: ; + } + break_2: ; + }}} + else + *next_operand++= *arg_p; + + next_option-> key= 0; + *next_operand= NULL; + *argc= next_operand - argv; + } + return opts; +} + +size_t gopt( const void *vptr_opts, int key ){ + const opt_t *opts= vptr_opts; + size_t count= 0; + for( ; opts-> key; ++opts ) + count+= opts-> key == key; + + return count; +} + +size_t gopt_arg( const void *vptr_opts, int key, const char **arg ){ + const opt_t *opts= vptr_opts; + size_t count= 0; + + for( ; opts-> key; ++opts ) + if( opts-> key == key ){ + if( ! count ) + *arg= opts-> arg; + ++count; + } + return count; +} + +const char *gopt_arg_i( const void *vptr_opts, int key, size_t i ){ + const opt_t *opts= vptr_opts; + + for( ; opts-> key; ++opts ) + if( opts-> key == key ){ + if( ! i ) + return opts-> arg; + --i; + } + return NULL; +} + +size_t gopt_args( const void *vptr_opts, int key, const char **args, size_t args_len ){ + const char **args_stop= args + args_len; + const char **args_ptr= args; + const opt_t *opts= vptr_opts; + + for( ; opts-> key; ++opts ) + if( opts-> key == key ){ + if( args_stop == args_ptr ) + return args_len + gopt( opts, key ); + + *args_ptr++= opts-> arg; + } + if( args_stop != args_ptr ) + *args_ptr= NULL; + return args_ptr - args; +} + +void gopt_free( void *vptr_opts ){ + free( vptr_opts ); +} diff --git a/pred_src/util/gopt.h b/pred_src/util/gopt.h new file mode 100644 index 0000000..27ef648 --- /dev/null +++ b/pred_src/util/gopt.h @@ -0,0 +1,60 @@ +/* gopt.h version 8.1: tom.viza@gmail.com PUBLIC DOMAIN 2003-8 */ +/* +I, Tom Vajzovic, am the author of this software and its documentation and +permanently abandon all copyright and other intellectual property rights in +them, including the right to be identified as the author. + +I am fairly certain that this software does what the documentation says it +does, but I cannot guarantee that it does, or that it does what you think it +should, and I cannot guarantee that it will not have undesirable side effects. + +You are free to use, modify and distribute this software as you please, but +you do so at your own risk. If you remove or hide this warning then you are +responsible for any problems encountered by people that you make the software +available to. + +Before modifying or distributing this software I ask that you would please +read http://www.purposeful.co.uk/tfl/ +*/ + +#ifndef GOPT_H_INCLUDED +#define GOPT_H_INCLUDED + +#define GOPT_ONCE 0 +#define GOPT_REPEAT 1 +#define GOPT_NOARG 0 +#define GOPT_ARG 2 + +#define gopt_start(...) (const void*)( const struct { int k; int f; const char *s; const char*const*l; }[]){ __VA_ARGS__, {0}} +#define gopt_option(k,f,s,l) { k, f, s, l } +#define gopt_shorts( ... ) (const char*)(const char[]){ __VA_ARGS__, 0 } +#define gopt_longs( ... ) (const char**)(const char*[]){ __VA_ARGS__, NULL } + + +void *gopt_sort( int *argc, const char **argv, const void *opt_specs ); +/* returns a pointer for use in the following calls + * prints to stderr and call exit() on error + */ +size_t gopt( const void *opts, int key ); +/* returns the number of times the option was specified + * which will be 0 or 1 unless GOPT_REPEAT was used + */ +size_t gopt_arg( const void *opts, int key, const char **arg ); +/* returns the number of times the option was specified + * writes a pointer to the option argument from the first (or only) occurance to *arg + */ +const char *gopt_arg_i( const void *opts, int key, size_t i ); +/* returns a pointer to the ith (starting at zero) occurance + * of the option, or NULL if it was not specified that many times + */ +size_t gopt_args( const void *opts, int key, const char **args, size_t args_len ); +/* returns the number of times the option was specified + * writes pointers to the option arguments in the order of occurance to args[]. + * writes at most args_len pointers + * if the return value is less than args_len, also writes a null pointer + */ +void gopt_free( void *opts ); +/* releases memory allocated in the corresponding call to gopt_sort() + * opts can no longer be used + */ +#endif /* GOPT_H_INCLUDED */ diff --git a/pred_src/util/random.c b/pred_src/util/random.c new file mode 100644 index 0000000..c8215a4 --- /dev/null +++ b/pred_src/util/random.c @@ -0,0 +1,52 @@ +// -------------------------------------------------------------- +// CU Spaceflight Landing Prediction +// Copyright (c) CU Spaceflight 2009, All Right Reserved +// +// Written by Rich Wareham +// +// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY +// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// -------------------------------------------------------------- + +#include "random.h" + +#include +#include + +// Sample from a normal distribution with zero mean and unit variance. +// See http://en.wikipedia.org/wiki/Normal_distribution +// #Generating_values_for_normal_random_variables +static float _random_sample_normal_intl(float* loglik) +{ + double u, v = 0.0; + static const double k = 0.918938533204673; // = 0.5 * (log(2) + log(pi)), see below. + + u = g_random_double(); + v = g_random_double(); + v = sqrt(-2.0 * log(u)) * cos(2.0 * G_PI * v); + + // actual likelihood is 1/sqrt(2*pi) exp(-(x^2)) since mu = 0 and sigma^2 = 1. + // log-likelihood is therefore: + // \ell(x) = - (x^2) - 0.5 * (log(2) + log(pi)) = - (x^2) - k + + if(loglik) + *loglik = (float) ( - (v*v) - k ); + + return v; +} + +float random_sample_normal(float mu, float sigma2, float *loglik) +{ + // Sample from our base case. + float v = _random_sample_normal_intl(loglik); + + // Transform into appropriate range. + v *= sqrt(sigma2); + v += mu; + + return v; +} + +// vim:sw=4:ts=4:et:cindent diff --git a/pred_src/util/random.h b/pred_src/util/random.h new file mode 100644 index 0000000..0ecf02f --- /dev/null +++ b/pred_src/util/random.h @@ -0,0 +1,23 @@ +// -------------------------------------------------------------- +// CU Spaceflight Landing Prediction +// Copyright (c) CU Spaceflight 2009, All Right Reserved +// +// Written by Rich Wareham +// +// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY +// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// -------------------------------------------------------------- + +#ifndef __RANDOM_H__ +#define __RANDOM_H__ + +// Return a random sample drawn from the normal distribution with mean mu and +// variance sigma2. If loglik is non-NULL, *loglik is set to the log-likelihood +// of drawing that sample. +float random_sample_normal(float mu, float sigma2, float *loglik); + +#endif /* __RANDOM_H__ */ + +// vim:sw=4:ts=4:et:cindent diff --git a/pred_src/wind/wind_file.c b/pred_src/wind/wind_file.c new file mode 100644 index 0000000..6075d93 --- /dev/null +++ b/pred_src/wind/wind_file.c @@ -0,0 +1,786 @@ +// -------------------------------------------------------------- +// CU Spaceflight Landing Prediction +// Copyright (c) CU Spaceflight 2009, All Right Reserved +// +// Written by Rich Wareham +// +// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY +// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// -------------------------------------------------------------- + +#include "wind_file.h" + +#include +#include +#include +#include + +#include "../util/getline.h" + +extern int verbosity; + +typedef struct wind_file_axis_s wind_file_axis_t; +struct wind_file_axis_s +{ + unsigned int n_values; + + // in actual fact, enough space is allocated for all values. + float values[1]; +}; + +struct wind_file_s +{ + // This is from the file header. + float lat, latrad; + float lon, lonrad; + unsigned long timestamp; + + // This describes the axes. + unsigned int n_axes; + wind_file_axis_t **axes; + + unsigned int n_components; + + // A pointer to the actual data. + float *data; +}; + +// These exciting functions are all to do with the fact that 'left' and 'right' +// is an interesting thing to talk about on a sphere. + +// Canonicalise a longitude into the range (0, 360]. +static float +_canonicalise_longitude(float lon) +{ + lon = fmodf(lon, 360.f); + if(lon < 0.f) + lon += 360.f; + assert((lon >= 0.f) && (lon < 360.f)); + return lon; +} + +// Return the 'distance' between two canonical longitudes. This will never +// exceed 180 degrees. +static float +_longitude_distance(float lon_a, float lon_b) +{ + float d1 = fabsf(lon_a - lon_b); + float d2 = 360.f - d1; + return (d1 < d2) ? d1 : d2; +} + +// Given two canonical longitudes, return non-zero iff lon_a is 'left' of lon_b +// or the same. 'Left' means that the number of degrees east one needs to go +// from lon_a to get to lon_b is < 180. +static int +_longitude_is_left_of(float lon_a, float lon_b) +{ + float deg_east; + + lon_a = _canonicalise_longitude(lon_a); + lon_b = _canonicalise_longitude(lon_b); + + deg_east = lon_b - lon_a; + if(deg_east < 0.f) + deg_east += 360.f; + if(deg_east >= 360.f) + deg_east -= 360.f; + + assert((deg_east >= 0.f) && (deg_east < 360.f)); + + return deg_east < 180.f; +} + +// Given two values return non-zero iff a is 'left' of b, i.e. a <= b. +static int +_float_is_left_of(float a, float b) +{ + return a <= b; +} + +// Given an axis, find the indicies of those values left and right of 'value'. +// Return non-zero if 'value' is outside of the axis range. Left is defined as +// 'rightmost value A where left_fun(A,value) returns non-zero' and 'right' is +// defined as 'leftmost value where left_fun(value,A) returns non-zero'. +static int +_wind_file_axis_find_value(wind_file_axis_t* axis, float value, + int (*left_fun) (float a, float b), + unsigned int* left, unsigned int* right) +{ + // NOTE: This function can't assume the axis is ordered since + // at least longitude doesn't work that way. Similarly pressure is + // ordered greatest to smallest and latitude is ordered smallest to + // greatest. + + unsigned int i; + float lval, rval; + + *left = *right = axis->n_values; + lval = rval = 0.f; + + // Look over all axis values. + for(i=0; in_values; ++i) + { + float axval = axis->values[i]; + if((!left_fun(axval,lval) || (*left==axis->n_values)) && left_fun(axval, value)) + { + *left = i; + lval = axval; + } + if((!left_fun(rval,axval) || (*right==axis->n_values)) && left_fun(value, axval)) + { + *right = i; + rval = axval; + } + } + return (*left != axis->n_values) && (*right != axis->n_values); +} + +// Scan forward in 'file' looking for the first line which is a non-comment +// line. Update *line with a pointer to the line which should be free-ed after +// use and update *n with the number of characters in that line. +static +int _get_non_comment_line(char** line, size_t *n, FILE* file) +{ + *line = NULL; + while((getline(line, n, file) >= 0) && ((*line)[0] == '#')) + { + // line does not need to be free-ed since getline will realloc + // it if it is too small. See getline(3). + } + + if(feof(file)) { + return -1; + } + + return *n; +} + +// Parse a line of the form value1,value2,...,valueN and add the values to the +// values array of axis. This array should have already been allocated and the +// function ignores any values beyond the number indicated in n_values. +// +// Returns non-zero on success. +static int +_parse_values_line(const char* line, unsigned int n_values, float* values) +{ + unsigned int record_idx = 0; + const char* record = line; + float value; + + while(1 == sscanf(record, "%f", &value)) { + if(record_idx >= n_values) + { + if(verbosity > 0) + fprintf(stderr, "WARN: Read too many values for axis " + "(%i, expected %i). " + "Ignoring them.\n", + record_idx, n_values); + } else { + values[record_idx] = value; + } + + // skip to end of record + while((*record != ',') && (*record != '\n') && (*record != '\0')) + record++; + + // and advance past delimiter + if(record != '\0') + record++; + + // update the record index + record_idx ++; + } + + // we define success as reading the number of values we expected. + return record_idx == n_values; +} + +wind_file_t* +wind_file_new(const char* filepath) +{ + FILE* file; + char* line = NULL; + size_t line_len; + int num_lines, num_axes, num_components, i; + wind_file_t* self; + + if(verbosity > 0) + fprintf(stderr, "INFO: Loading wind data from '%s'.\n", filepath); + + file = fopen(filepath, "r"); + if(!file) { + perror("ERROR: Could not open file."); + return NULL; + } + + // get the header + if(0 > _get_non_comment_line(&line, &line_len, file)) + { + fprintf(stderr, "ERROR: EOF before header.\n"); + fclose(file); + return NULL; + } + + self = (wind_file_t*)malloc(sizeof(wind_file_t)); + self->n_axes = 0; + self->axes = NULL; + self->data = NULL; + + if(5 != sscanf(line, "%f,%f,%f,%f,%ld", + &self->lat, &self->latrad, + &self->lon, &self->lonrad, + &self->timestamp)) + { + fprintf(stderr, "ERROR: Error parsing header '%s'.\n", line); + free(line); + fclose(file); + wind_file_free(self); + return NULL; + } + free(line); + + // get the axis count + if(0 > _get_non_comment_line(&line, &line_len, file)) + { + fprintf(stderr, "ERROR: EOF before axis count.\n"); + fclose(file); + wind_file_free(self); + return NULL; + } + num_axes = atoi(line); + free(line); + + self->n_axes = num_axes; + + // use calloc(3) so that we initialise everything to NULL. + self->axes = (wind_file_axis_t**)calloc(num_axes, sizeof(wind_file_axis_t*)); + + // process each axis + for(i=0; i _get_non_comment_line(&line, &line_len, file)) + { + fprintf(stderr, "ERROR: EOF before axis value count.\n"); + fclose(file); + wind_file_free(self); + return NULL; + } + num_values = atoi(line); + free(line); + + if(num_values < 1) + { + fprintf(stderr, "ERROR: axis %i count is < 1.\n", i); + fclose(file); + wind_file_free(self); + return NULL; + } + + self->axes[i] = (wind_file_axis_t*) + malloc(sizeof(wind_file_axis_t) + sizeof(float)*(num_values-1)); + self->axes[i]->n_values = num_values; + + // get the axis line + if(0 > _get_non_comment_line(&line, &line_len, file)) + { + fprintf(stderr, "ERROR: EOF before axis value line.\n"); + fclose(file); + wind_file_free(self); + return NULL; + } + + if(!_parse_values_line(line, self->axes[i]->n_values, self->axes[i]->values)) + { + fprintf(stderr, "ERROR: Error parsing axis value line.\n"); + fclose(file); + free(line); + wind_file_free(self); + return NULL; + } + + free(line); + } + + // get the line count + if(0 > _get_non_comment_line(&line, &line_len, file)) + { + fprintf(stderr, "ERROR: EOF before line count.\n"); + fclose(file); + free(line); + wind_file_free(self); + return NULL; + } + + num_lines = atoi(line); + free(line); + + // get the datum component count + if(0 > _get_non_comment_line(&line, &line_len, file)) + { + fprintf(stderr, "ERROR: EOF before datum component count.\n"); + fclose(file); + free(line); + wind_file_free(self); + return NULL; + } + + num_components = atoi(line); + free(line); + self->n_components = num_components; + + // check number of lines matches what we expect + { + int expected_line_count = 1; + for(i=0; in_axes; ++i) + { + expected_line_count *= self->axes[i]->n_values; + } + if(expected_line_count != num_lines) + { + fprintf(stderr, "ERROR: Data axes imply %i records. " + "The file header claims %i.\n", + expected_line_count, + num_lines); + fclose(file); + wind_file_free(self); + return NULL; + } + } + + if(verbosity > 0) + fprintf(stderr, "INFO: Data is %i axis made up of " + "(%i records) x (%i components).\n", + num_axes, num_lines, num_components); + + // we have everything we need to actually read the data now. Allocate an + // array to store it. + self->data = (float*)malloc(sizeof(float) * num_lines * num_components); + + // and iterate reading data. FIXME: Extra data is currently ignored silently. + // we should probably check there are no non-comment lines after the data. + for(i=0; i _get_non_comment_line(&line, &line_len, file)) || + (!_parse_values_line(line, num_components, &(self->data[num_components*i])))) + { + fprintf(stderr, "ERROR: Could not parse data line %i of file. " + "The file may be corrupt or truncated.\n", + i); + free(line); + fclose(file); + wind_file_free(self); + return NULL; + } + + // if we succeed, we need to free the line. + free(line); + } + + // close the file since we're done with it now. + fclose(file); + + if(self->n_axes != 3) + { + fprintf(stderr, "ERROR: Expected 3 axes in file.\n"); + wind_file_free(self); + return NULL; + } + + if(self->n_components != 3) + { + fprintf(stderr, "ERROR: Expected 3 component data in file.\n"); + wind_file_free(self); + return NULL; + } + + return self; +} + +void +wind_file_free(wind_file_t* file) +{ + if(!file) + return; + + if(file->n_axes > 0) + { + unsigned int i; + for(i=0; in_axes; ++i) + { + if(file->axes[i]) + { + free(file->axes[i]); + } + } + free(file->axes); + } + + if(file->data) + { + free(file->data); + } + + free(file); +} + +static float* +_wind_file_get_record(wind_file_t* file, + unsigned int lat_idx, unsigned int lon_idx, + unsigned int pressure_idx) +{ + size_t offset = file->n_components * + (lon_idx + + file->axes[2]->n_values * + (lat_idx + file->axes[1]->n_values * pressure_idx)); + return &(file->data[offset]); +} + +static float +_wind_file_get_height(wind_file_t* file, + unsigned int lat_idx, unsigned int lon_idx, + unsigned int pressure_idx) +{ + return _wind_file_get_record(file, lat_idx, lon_idx, pressure_idx)[0]; +} + +static void +_wind_file_get_wind_raw(wind_file_t* file, + unsigned int lat_idx, unsigned int lon_idx, + unsigned int pressure_idx, + float *u, float* v) +{ + float* record = _wind_file_get_record(file, lat_idx, lon_idx, pressure_idx); + *u = record[1]; *v = record[2]; +} + +static float +_lerp(float a, float b, float lambda) +{ + return a * (1.f - lambda) + b * lambda; +} + +static float +_bilinear_interpolate(float ll, float lr, float rl, float rr, float lambda1, float lambda2) +{ + float il = _lerp(ll, rl, lambda1); + float ir = _lerp(lr, rr, lambda1); + return _lerp(il,ir,lambda2); +} + +void +wind_file_get_wind(wind_file_t* file, float lat, float lon, float height, + float* windu, float *windv, float *uvar, float *vvar) +{ + // we use static variables to 'cache' the last left and right lat/longs + // and heights so that we can avoid searching the axes if necessary + static int have_valid_latlon_cache = 0; + static int have_valid_pressure_cache = 0; + + static unsigned int left_lat_idx, right_lat_idx; + static unsigned int left_lon_idx, right_lon_idx; + static unsigned int left_pr_idx, right_pr_idx; + + static float left_lat, right_lat; + static float left_lon, right_lon; + + int i; + float left_height, right_height; + float lat_lambda, lon_lambda, pr_lambda; + + assert(file); + assert(windu && windv); + + // canonicalise the longitude + lon = _canonicalise_longitude(lon); + + // by default, return nothing in case of error. + *windu = *windv = 0.f; + + // see if the cache is indeed valid + if(have_valid_latlon_cache) + { + if((left_lat > lat) || + (right_lat < lat) || + !_longitude_is_left_of(left_lon, lon) || + !_longitude_is_left_of(lon, right_lon)) + { + have_valid_latlon_cache = 0; + } + } + + // if we have no cached grid locations, look for them. + if(!have_valid_latlon_cache) + { + // look for latitude along second axis + if(!_wind_file_axis_find_value(file->axes[1], lat, + _float_is_left_of, &left_lat_idx, &right_lat_idx)) + { + if(verbosity > 0) + fprintf(stderr, "WARN: Latitude %f is not covered by file.\n", lat); + return; + } + left_lat = file->axes[1]->values[left_lat_idx]; + right_lat = file->axes[1]->values[right_lat_idx]; + + // look for longitude along third axis + if(!_wind_file_axis_find_value(file->axes[2], lon, + _longitude_is_left_of, &left_lon_idx, &right_lon_idx)) + { + if(verbosity > 0) + fprintf(stderr, "WARN: Longitude %f is not covered by file.\n", lon); + return; + } + left_lon = file->axes[2]->values[left_lon_idx]; + right_lon = file->axes[2]->values[right_lon_idx]; + + if(verbosity > 1) + fprintf(stderr, "INFO: Moved to latitude/longitude " + "cell (%f,%f)-(%f,%f)\n", + left_lat, left_lon, right_lat, right_lon); + + have_valid_latlon_cache = 1; + } + + // compute the normalised lat/lon co-ordinate within the cell we're in. + if(left_lat_idx != right_lat_idx) + lat_lambda = (lat - left_lat) / (right_lat - left_lat); + else + lat_lambda = 0.5f; + + if(left_lon_idx != right_lon_idx) + lon_lambda = _longitude_distance(lon, left_lon) + / _longitude_distance(right_lon, left_lon); + else + lon_lambda = 0.5f; + + // munge the lambdas into the right range. Numerical approximations can nudge them + // ~1e-08 either side sometimes. + lat_lambda = (lat_lambda < 0.f) ? 0.f : lat_lambda; + lat_lambda = (lat_lambda > 1.f) ? 1.f : lat_lambda; + lon_lambda = (lon_lambda < 0.f) ? 0.f : lon_lambda; + lon_lambda = (lon_lambda > 1.f) ? 1.f : lon_lambda; + + // use this normalised co-ordinate to check the left and right heights + if(have_valid_pressure_cache) + { + float ll_height, lr_height, rl_height, rr_height; + + // left + ll_height = _wind_file_get_height(file, left_lat_idx, left_lon_idx, left_pr_idx); + lr_height = _wind_file_get_height(file, left_lat_idx, right_lon_idx, left_pr_idx); + rl_height = _wind_file_get_height(file, right_lat_idx, left_lon_idx, left_pr_idx); + rr_height = _wind_file_get_height(file, right_lat_idx, right_lon_idx, left_pr_idx); + left_height = _bilinear_interpolate(ll_height, lr_height, rl_height, rr_height, + lat_lambda, lon_lambda); + // if the leftmost height is too small and we can go lower... + if((left_height > height) && (left_pr_idx > 0)) + have_valid_pressure_cache = 0; + + // right + ll_height = _wind_file_get_height(file, left_lat_idx, left_lon_idx, right_pr_idx); + lr_height = _wind_file_get_height(file, left_lat_idx, right_lon_idx, right_pr_idx); + rl_height = _wind_file_get_height(file, right_lat_idx, left_lon_idx, right_pr_idx); + rr_height = _wind_file_get_height(file, right_lat_idx, right_lon_idx, right_pr_idx); + right_height = _bilinear_interpolate(ll_height, lr_height, rl_height, rr_height, + lat_lambda, lon_lambda); + // if the rightmost height is too small and we can go higher... + if((right_height < height) && (right_pr_idx < file->axes[0]->n_values-1)) + have_valid_pressure_cache = 0; + } + + // if our height cache is out of whack, find a better cell. + if(!have_valid_pressure_cache) + { + // search along all heights to find what pressure level we're at + left_pr_idx = right_pr_idx = file->axes[0]->n_values; + left_height = right_height = -1.f; + for(i=0; iaxes[0]->n_values; ++i) + { + // get heights for each corner of our lat/lon cell. + float ll_height = _wind_file_get_height(file, + left_lat_idx, left_lon_idx, i); + float lr_height = _wind_file_get_height(file, + left_lat_idx, right_lon_idx, i); + float rl_height = _wind_file_get_height(file, + right_lat_idx, left_lon_idx, i); + float rr_height = _wind_file_get_height(file, + right_lat_idx, right_lon_idx, i); + + // interpolate within our cell. + float interp_height = _bilinear_interpolate( + ll_height, lr_height, rl_height, rr_height, + lat_lambda, lon_lambda); + + if((interp_height <= height) && + ((interp_height >= left_height) || + (left_pr_idx == file->axes[0]->n_values))) + { + left_pr_idx = i; + left_height = interp_height; + } + + if((interp_height >= height) && + ((interp_height <= right_height) || + (right_pr_idx == file->axes[0]->n_values))) + { + right_pr_idx = i; + right_height = interp_height; + } + } + + if(left_pr_idx == file->axes[0]->n_values) + { + left_pr_idx = right_pr_idx; + if(verbosity > 0) + fprintf(stderr, "WARN: Moved to %.2fm, below height where we " + "have data. " + "Assuming we're at %.fmb or approx. %.2fm.\n", + height, + file->axes[0]->values[left_pr_idx], + _wind_file_get_height(file, + left_lat_idx, left_lon_idx, left_pr_idx)); + } + + if(right_pr_idx == file->axes[0]->n_values) + { + right_pr_idx = left_pr_idx; + if(verbosity > 0) + fprintf(stderr, "WARN: Moved to %.2fm, above height where we " + "have data. " + "Assuming we're at %.fmb or approx. %.2fm.\n", + height, + file->axes[0]->values[right_pr_idx], + _wind_file_get_height(file, + left_lat_idx, left_lon_idx, right_pr_idx)); + } + + if((left_pr_idx == file->axes[0]->n_values) || + (right_pr_idx == file->axes[0]->n_values)) + { + fprintf(stderr, "ERROR: Moved to a totally stupid height (%f). " + "Giving up!\n", height); + return; + } + + if(verbosity > 1) + fprintf(stderr, "INFO: Moved to pressure cell (%.fmb, %.fmb)\n", + file->axes[0]->values[left_pr_idx], + file->axes[0]->values[right_pr_idx]); + + have_valid_pressure_cache = 1; + } + + // compute the normalised pressure co-ordinate within the cell we're in. + if(left_pr_idx != right_pr_idx) + pr_lambda = (height - left_height) / (right_height - left_height); + else + pr_lambda = 0.5f; + + // pr_lambda might be outside of the range [0,1] depending on if we went + // above or below our data, munge it appropriately. + pr_lambda = (pr_lambda < 0.f) ? 0.f : pr_lambda; + pr_lambda = (pr_lambda > 1.f) ? 1.f : pr_lambda; + + assert(lat_lambda >= 0.f); + assert(lon_lambda >= 0.f); + assert(pr_lambda >= 0.f); + assert(lat_lambda <= 1.f); + assert(lon_lambda <= 1.f); + assert(pr_lambda <= 1.f); + + // By this point we have left/right co-ordinates which describe the + // latitude, longitude and pressure boundaries of our data cell along + // with normalised co-ordinates within it. We can now actually find + // some data... + // + // We compute the lerped u and v along with the neighbourhood mean and + // square mean to calculate the neighbourhood variance. + { + float llu, lru, rlu, rru; + float llv, lrv, rlv, rrv; + + float lowu, lowv, highu, highv; + + float umean = 0.f; + float usqmean = 0.f; + float vmean = 0.f; + float vsqmean = 0.f; + + // let's get the wind u and v for the lower lat/lon cell + _wind_file_get_wind_raw(file, + left_lat_idx, left_lon_idx, left_pr_idx, &llu, &llv); + _wind_file_get_wind_raw(file, + left_lat_idx, right_lon_idx, left_pr_idx, &lru, &lrv); + _wind_file_get_wind_raw(file, + right_lat_idx, left_lon_idx, left_pr_idx, &rlu, &rlv); + _wind_file_get_wind_raw(file, + right_lat_idx, right_lon_idx, left_pr_idx, &rru, &rrv); + + lowu = _bilinear_interpolate(llu, lru, rlu, rru, lat_lambda, lon_lambda); + lowv = _bilinear_interpolate(llv, lrv, rlv, rrv, lat_lambda, lon_lambda); + + umean = llu + lru + rlu + rru; + vmean = llv + lrv + rlv + rrv; + usqmean = llu*llu + lru*lru + rlu*rlu + rru*rru; + vsqmean = llv*llv + lrv*lrv + rlv*rlv + rrv*rrv; + + /* + lowusq = _bilinear_interpolate(llu*llu, lru*lru, rlu*rlu, rru*rru, + lat_lambda, lon_lambda); + lowvsq = _bilinear_interpolate(llv*llv, lrv*lrv, rlv*rlv, rrv*rrv, + lat_lambda, lon_lambda); + */ + + // let's get the wind u and v for the upper lat/lon cell + _wind_file_get_wind_raw(file, + left_lat_idx, left_lon_idx, right_pr_idx, &llu, &llv); + _wind_file_get_wind_raw(file, + left_lat_idx, right_lon_idx, right_pr_idx, &lru, &lrv); + _wind_file_get_wind_raw(file, + right_lat_idx, left_lon_idx, right_pr_idx, &rlu, &rlv); + _wind_file_get_wind_raw(file, + right_lat_idx, right_lon_idx, right_pr_idx, &rru, &rrv); + + highu = _bilinear_interpolate(llu, lru, rlu, rru, lat_lambda, lon_lambda); + highv = _bilinear_interpolate(llv, lrv, rlv, rrv, lat_lambda, lon_lambda); + + umean += llu + lru + rlu + rru; + vmean += llv + lrv + rlv + rrv; + usqmean += llu*llu + lru*lru + rlu*rlu + rru*rru; + vsqmean += llv*llv + lrv*lrv + rlv*rlv + rrv*rrv; + + /* + highusq = _bilinear_interpolate(llu*llu, lru*lru, rlu*rlu, rru*rru, + lat_lambda, lon_lambda); + highvsq = _bilinear_interpolate(llv*llv, lrv*lrv, rlv*rlv, rrv*rrv, + lat_lambda, lon_lambda); + */ + + *windu = _lerp(lowu, highu, pr_lambda); + *windv = _lerp(lowv, highv, pr_lambda); + + // We will calculate the variance by making use of the fact + // that the lerping is effectively a weighted mean or + // expectation and that + // var = E[X^2] - E[X]^2. + // + // In effect this calculates the instantaneous variance by considering the + // contributions from the cube surrounding the point in question. + // This is highly cunning and, on the face of it, not entirely wrong. + + umean *= 0.125f; usqmean *= 0.125f; + vmean *= 0.125f; vsqmean *= 0.125f; + + *uvar = usqmean - umean * umean; + *vvar = vsqmean - vmean * vmean; + } +} + +// Data for God's own editor. +// vim:sw=8:ts=8:et:cindent diff --git a/pred_src/wind/wind_file.h b/pred_src/wind/wind_file.h new file mode 100644 index 0000000..c141388 --- /dev/null +++ b/pred_src/wind/wind_file.h @@ -0,0 +1,48 @@ +// -------------------------------------------------------------- +// CU Spaceflight Landing Prediction +// Copyright (c) CU Spaceflight 2009, All Right Reserved +// +// Written by Rich Wareham +// +// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY +// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// -------------------------------------------------------------- + +#ifndef __WIND_FILE_H__ +#define __WIND_FILE_H__ + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// An opaque type representing the cache itself. +typedef struct wind_file_s wind_file_t; + +// An opaque type representing a cache entry. +typedef struct wind_file_entry_s wind_file_entry_t; + +// Open 'file' and parse contents. Return NULL on failure. +wind_file_t *wind_file_new (const char *file); + +// Free resources associated with 'file'. +void wind_file_free (wind_file_t *file); + +void wind_file_get_wind (wind_file_t *file, + float lat, + float lon, + float height, + float *windu, + float *windv, + float *windusq, + float *windvsq); + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // __WIND_FILE_H__ + +// Data for God's own editor. +// vim:sw=8:ts=8:et:cindent diff --git a/pred_src/wind/wind_file_cache.c b/pred_src/wind/wind_file_cache.c new file mode 100644 index 0000000..5a2ed76 --- /dev/null +++ b/pred_src/wind/wind_file_cache.c @@ -0,0 +1,357 @@ +// -------------------------------------------------------------- +// CU Spaceflight Landing Prediction +// Copyright (c) CU Spaceflight 2009, All Right Reserved +// +// Written by Rich Wareham +// +// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY +// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// -------------------------------------------------------------- + +#include "wind_file_cache.h" +#include "wind_file.h" + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "../util/getline.h" + +extern int verbosity; + +struct wind_file_cache_entry_s +{ + char *filepath; // Full path. + unsigned long timestamp; // As POSIX timestamp. + float lat, lon; // Window centre. + float latrad, lonrad; // Window radius. + wind_file_t *loaded_file; // Initially NULL. +}; + +struct wind_file_cache_s +{ + char *directory_name; + unsigned int n_entries; + struct wind_file_cache_entry_s **entries; // Matching directory entries. +}; + +// Yuk! Needed to make use of scandir. Gotta love APIs designed in the 80s. +static wind_file_cache_t* _scandir_current_cache; + +static int +_parse_header(const char* filepath, + float *lat, float *latrad, + float *lon, float *lonrad, + unsigned long* timestamp) +{ + FILE* file; + char* line; + size_t line_len; + + // Can I open this file? + file = fopen(filepath, "r"); + if(!file) { + // No, abort + return 0; + } + + // Look for first non-comment line. + line = NULL; + while((getline(&line, &line_len, file) >= 0) && (line[0] == '#')) + { + // line does not need to be free-ed since getline will realloc + // it if it is too small. See getline(3). + } + + if(feof(file)) + { + // Got to the end without finding non-comment. + free(line); + fclose(file); + return 0; + } + + + // 'line' is first non-comment. Try to parse it. + if(5 != sscanf(line, "%f,%f,%f,%f,%ld", lat, latrad, lon, lonrad, timestamp)) + { + // Failed to parse, it is invalid. + free(line); + fclose(file); + return 0; + } + + // File seems valid. + free(line); + fclose(file); + + return 1; +} + +#ifdef __APPLE__ +static int +_file_filter(struct dirent *entry) +#else +static int +_file_filter(const struct dirent *entry) +#endif +{ + int filepath_len; + int rv; + wind_file_cache_t* self = _scandir_current_cache; + char* filepath = NULL; + struct stat stat_buf; + + float lat, latrad, lon, lonrad; + unsigned long timestamp; + + // This is using sprintf in C99 mode to create a buffer with + // the full file path/ + filepath_len = 1 + snprintf(NULL, 0, "%s/%s", self->directory_name, entry->d_name); + filepath = (char*)malloc(filepath_len); + snprintf(filepath, filepath_len, "%s/%s", self->directory_name, entry->d_name); + + // Stat the file. + rv = stat(filepath, &stat_buf); + if(rv < 0) + { + perror("Error scanning data dir"); + free(filepath); + return 0; + } + + // Is this a regular file? + if(!S_ISREG(stat_buf.st_mode)) + { + free(filepath); + return 0; + } + + // Can I parse out the header? + if(!_parse_header(filepath, &lat, &latrad, &lon, &lonrad, ×tamp)) + { + free(filepath); + return 0; + } + + free(filepath); + + return 1; +} + +wind_file_cache_t* +wind_file_cache_new(const char *directory) +{ + wind_file_cache_t* self; + int rv, i; + struct dirent **dir_entries; + + assert(directory); + + // Allocate memory for ourself + self = (wind_file_cache_t*) malloc(sizeof(wind_file_cache_t)); + self->n_entries = 0; + self->directory_name = strdup(directory); + + if(verbosity > 0) + fprintf(stderr, "INFO: Scanning directory '%s'.\n", directory); + + // Use scandir scan the directory looking for data files. + _scandir_current_cache = self; // ew! + rv = scandir(directory, &dir_entries, _file_filter, alphasort); + if(rv < 0) { + perror(NULL); + wind_file_cache_free(self); + return NULL; + } + if(verbosity > 0) + fprintf(stderr, "INFO: Found %i data files.\n", rv); + self->n_entries = rv; + + self->entries = (struct wind_file_cache_entry_s**)malloc(sizeof(struct wind_file_cache_entry_s*)*self->n_entries); + for(i=0; in_entries; ++i) + { + struct dirent* entry = dir_entries[i]; + int filepath_len, parse_rv; + char* filepath = NULL; + + // allocate the entry. + self->entries[i] = (struct wind_file_cache_entry_s*)malloc(sizeof(struct wind_file_cache_entry_s)); + + // This is using sprintf in C99 mode to create a buffer with + // the full file path/ + filepath_len = 1 + snprintf(NULL, 0, "%s/%s", self->directory_name, entry->d_name); + filepath = (char*)malloc(filepath_len); + snprintf(filepath, filepath_len, "%s/%s", self->directory_name, entry->d_name); + + // Fill in the file path. + self->entries[i]->filepath = filepath; + + // Parse the file header + parse_rv = _parse_header(filepath, + &(self->entries[i]->lat), &(self->entries[i]->latrad), + &(self->entries[i]->lon), &(self->entries[i]->lonrad), + &(self->entries[i]->timestamp)); + if(!parse_rv) + { + fprintf(stderr, "WARN: Hmm... some files appear to have " + "changed under me!"); + } + + if(verbosity > 1) { + fprintf(stderr, "INFO: Found %s.\n", filepath); + fprintf(stderr, "INFO: - Covers window (lat, long) = " + "(%f +/-%f, %f +/-%f).\n", + self->entries[i]->lat, self->entries[i]->latrad, + self->entries[i]->lon, self->entries[i]->lonrad); + } + + // initially, no file is loaded. + self->entries[i]->loaded_file = NULL; + + // finished with this entry + free(dir_entries[i]); + } + // finished with the dir entries. + free(dir_entries); + + return self; +} + +void +wind_file_cache_free(wind_file_cache_t *cache) +{ + if(!cache) + return; + + free(cache->directory_name); + + if(cache->n_entries > 0) + { + unsigned int i; + for(i=0; in_entries; ++i) + { + free(cache->entries[i]->filepath); + free(cache->entries[i]); + cache->entries[i] = NULL; + } + free(cache->entries); + } + + free(cache); +} + +static float +_lon_dist(float a, float b) +{ + float d1 = fabs(a-b); + float d2 = 360.f - d1; + return (d1 < d2) ? d1 : d2; +} + +int +wind_file_cache_entry_contains_point(wind_file_cache_entry_t* entry, float lat, float lon) +{ + if(!entry) + return 0; + + if(fabs(entry->lat - lat) > entry->latrad) + return 0; + + if(_lon_dist(entry->lon, lon) > entry->lonrad) + return 0; + + return 1; +} + +void +wind_file_cache_find_entry(wind_file_cache_t *cache, + float lat, float lon, unsigned long timestamp, + wind_file_cache_entry_t** earlier, + wind_file_cache_entry_t** later) +{ + assert(cache && earlier && later); + + *earlier = *later = NULL; + + // This is the best we can do if we have no entries. + if(cache->n_entries == 0) + return; + + // Search for earlier and later entries which match + unsigned int i; + for(i=0; in_entries; ++i) + { + wind_file_cache_entry_t* entry = cache->entries[i]; + + if(entry->timestamp <= timestamp) { + // This is an earlier entry + if(!(*earlier) || (entry->timestamp > (*earlier)->timestamp)) + { + if(wind_file_cache_entry_contains_point(entry,lat,lon)) + *earlier = entry; + } + } else { + // This is a later entry + if(!(*later) || (entry->timestamp < (*later)->timestamp)) { + if(wind_file_cache_entry_contains_point(entry,lat,lon)) + *later = entry; + } + } + } + + if(!*earlier) { *earlier = *later; } + if(!*later) { *later = *earlier; } + + // If all else fails, just choose the first entry. + if(!*earlier) { *earlier = *later = cache->entries[0]; } +} + +const char* +wind_file_cache_entry_file_path(wind_file_cache_entry_t* entry) +{ + if(!entry) + return NULL; + return entry->filepath; +} + +unsigned int +wind_file_cache_entry_timestamp(wind_file_cache_entry_t* entry) +{ + if(!entry) + return 0; + return entry->timestamp; +} + +wind_file_t* +wind_file_cache_entry_file(wind_file_cache_entry_t *entry) +{ + const char* filepath; + + if(!entry) + return NULL; + + if(entry->loaded_file) + return entry->loaded_file; + + filepath = wind_file_cache_entry_file_path(entry); + if(!filepath) + return NULL; + + entry->loaded_file = wind_file_new(filepath); + return entry->loaded_file; +} + +// Data for God's own editor. +// vim:sw=8:ts=8:et:cindent diff --git a/pred_src/wind/wind_file_cache.h b/pred_src/wind/wind_file_cache.h new file mode 100644 index 0000000..0954af2 --- /dev/null +++ b/pred_src/wind/wind_file_cache.h @@ -0,0 +1,79 @@ +// -------------------------------------------------------------- +// CU Spaceflight Landing Prediction +// Copyright (c) CU Spaceflight 2009, All Right Reserved +// +// Written by Rich Wareham +// +// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY +// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// -------------------------------------------------------------- + +#ifndef __WIND_FILES_H__ +#define __WIND_FILES_H__ + +#include "wind_file.h" + +// A cache which scans the wind data directory for data files, tries to read +// the header and parse out their timestamp and window information. It then +// allows one to query for files closest in time and space for a specified +// latitude/longitude/time. + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// An opaque type representing the cache itself. +typedef struct wind_file_cache_s wind_file_cache_t; + +// An opaque type representing a cache entry. +typedef struct wind_file_cache_entry_s wind_file_cache_entry_t; + +// Scan 'directory' for wind files. Return a new cache. +wind_file_cache_t *wind_file_cache_new (const char *directory); + +// Free resources associated with 'cache'. +void wind_file_cache_free (wind_file_cache_t *cache); + +// Search for a cache entry closest to the specified lat, lon and time. +// *earlier and *later are set to the nearest cache entries which are +// (respectively) earlier and later. +void wind_file_cache_find_entry + (wind_file_cache_t *cache, + float lat, + float lon, + unsigned long timestamp, + wind_file_cache_entry_t **earlier, + wind_file_cache_entry_t **later); + +// Return non-zero if the cache entry specifies contains the latitude +// and longitude. +int wind_file_cache_entry_contains_point + (wind_file_cache_entry_t *entry, + float lat, + float lon); + +// Return a string which gives the full path to the wind file +// corresponding to 'entry'. This should not be freed since it +// is owned by the cache itself. +const char* wind_file_cache_entry_file_path + (wind_file_cache_entry_t *entry); + +// Return the timestamp of the specified cache entry. +unsigned int wind_file_cache_entry_timestamp + (wind_file_cache_entry_t *entry); + +// Return the file for of the specified cache entry loading it if +// necessary. +wind_file_t* wind_file_cache_entry_file + (wind_file_cache_entry_t *entry); + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // __WIND_FILES_H__ + +// Data for God's own editor. +// vim:sw=8:ts=8:et:cindent