示例#1
0
    $p->SetFileFormat('jpg');
    $p->SetBgImage($image_filename, 'scale');
    $p->SetDataType('text-data');
    $p->SetDrawXAxis(False);
    $p->SetDrawYAxis(False);
    $p->SetDataValues($data);
    $p->SetXDataLabelPos('none');
    $p->SetXTickLabelPos('none');
    $p->SetYTickLabelPos('none');
    $p->SetXTickPos('none');
    $p->SetYTickPos('none');
    $p->SetDrawYGrid(False);
    $p->SetDataColors($histogram_color, NULL, $histogram_alpha);
    $p->SetPlotType('thinbarline');
    if ($draw_border) {
        $p->SetGridColor($border_color);
        $p->SetPlotBorderType('full');
    } else {
        $p->SetPlotBorderType('none');
    }
    # Compute the position of the histogram plot within the image.
    $hx0 = (int) ($hx * $plot_image_width);
    $hy0 = (int) ($hy * $plot_image_height);
    $hx1 = (int) ($h_width * $plot_image_width) + $hx0;
    $hy1 = (int) ($h_height * $plot_image_height) + $hy0;
    $p->SetPlotAreaPixels($hx0, $hy0, $hx1, $hy1);
    $p->DrawGraph();
}
/* Demo main. */
plot_histogram('examples/geese.jpg', $param);
示例#2
0
function make_quake_stats()
{
    // This function list the quakes //
    $path = "./";
    $dir_handle = @opendir($path) or die("Unable to open folder");
    $a = 0;
    $files = array();
    while (false !== ($file1 = readdir($dir_handle))) {
        $files[] = $file1;
    }
    sort($files);
    $files = array_reverse($files);
    //Count # of files that are not junk
    $aa = 0;
    $aaa = 0;
    foreach ($files as $file1) {
        if (is_dir($file1)) {
            if ($file1 != "." && $file1 != ".." && $file1 != "JUNK" && $file1 != "SAFE" && $file1 != "view" && $file1 != "inc" && $file1 != "images") {
                $aa++;
            }
        }
    }
    $ABC = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
    $time_file = BASEPATH . "/qcnwp/earthquakes/stats/time_v_iteration.txt";
    $mag_file = BASEPATH . "/qcnwp/earthquakes/stats/mag_v_iteration.txt";
    $mt_file = BASEPATH . "/qcnwp/earthquakes/stats/mag_v_time.txt";
    $time_now = time();
    $ft = fopen($time_file, 'w');
    $fm = fopen($mag_file, 'w');
    $fmt = fopen($mt_file, 'w');
    // For each event direcory, output a line of of a table //
    for ($i = 0; $i < 7; $i++) {
        $aaa = 0;
        //  $i++;
        $qmag_arr = array();
        $dt_detect = array();
        foreach ($files as $file1) {
            $a++;
            if (is_dir($file1)) {
                if ($file1 != "." && $file1 != ".." && $file1 != "JUNK" && $file1 != "SAFE" && $file1 != "view" && $file1 != "inc" && $file1 != "images") {
                    $efile = "{$file1}/{$ABC[$i]}/event.xy";
                    if (file_exists($efile)) {
                        $aaa++;
                        $etime = (int) $file1;
                        $contents = file($efile);
                        $string = implode($contents);
                        list($qlon, $qlat, $qdep, $qmag, $ntrig, $etime, $dtime, $qstd) = split('[,]', $string);
                        $qmag_arr[$aaa - 1] = $qmag;
                        $dt_detect[$aaa - 1] = $dtime - $etime;
                        $days[$aaa - 1] = (int) (($etime - $time_now) / 60.0 / 60.0 / 24.0);
                    }
                }
            }
        }
        $med_m = plot_histogram($qmag_arr, $xmin = 3, $xmax = 7, $ymin = 0.1, $ymax = 35, $dx = 0.25, "Magnitude", "Frequency", "Magnitude Distribution", $file_name = "magnitude_" . $i, $plt_med = "y");
        $med_t = plot_histogram($dt_detect, $xmin = 0, $xmax = 30, $ymin = 0.1, $ymax = 25, $dx = 1, "Detection Times", "Frequency", "Detection Time Distribution", $file_name = "dt_detect_" . $i, $plt_med = "y");
        // Histogram of # of earthquakes detected:
        if ($i == 0) {
            $xmin = min($days);
            if ($xmin < -180) {
                $xmin = -180;
            }
            $xmax = 0;
            //   echo "$xmin, $xmax\n";
            $med_eq = plot_histogram($days, $xmin, $xmax, $ymin = 0, $ymax = 25, $dx = 1, "Days Ago", "Frequency", "Earthquake Distribution", $file_name = "earthquake_through_time", $plt_med = "n");
        }
        fwrite($fm, $i + 1 . ",{$med_m}\n");
        fwrite($ft, $i + 1 . ",{$med_t}\n");
        fwrite($fmt, "{$med_t},{$med_m}\n");
    }
    fclose($fm);
    fclose($ft);
    fclose($fmt);
    closedir($dir_handle);
    psxy($time_file, $xmn = 0, $xmx = 10, $ymn = 0, $ymx = 20, "Iteration", "Time", "Detection Time per Iteration", "time_v_iter");
    psxy($mag_file, $xmn = 0, $xmx = 10, $ymn = 3, $ymx = 7, "Iteration", "Magnitude", "Magnitude per Iteration", "mag_v_iter");
    psxy($mt_file, $xmn = 0, $xmx = 20, $ymn = 2, $ymx = 7, "Time (s)", "Magnitude", "Magitude v. Detection Time", "mag_v_time");
}
示例#3
0
    $p->SetFileFormat('jpg');
    $p->SetBgImage($image_filename, 'scale');
    $p->SetDataType('text-data');
    $p->SetDrawXAxis(False);
    $p->SetDrawYAxis(False);
    $p->SetDataValues($data);
    $p->SetXDataLabelPos('none');
    $p->SetXTickLabelPos('none');
    $p->SetYTickLabelPos('none');
    $p->SetXTickPos('none');
    $p->SetYTickPos('none');
    $p->SetDrawYGrid(False);
    $p->SetDataColors($histogram_color, NULL, $histogram_alpha);
    $p->SetPlotType('thinbarline');
    if ($draw_border) {
        $p->SetGridColor($border_color);
        $p->SetPlotBorderType('full');
    } else {
        $p->SetPlotBorderType('none');
    }
    # Compute the position of the histogram plot within the image.
    $hx0 = (int) ($hx * $plot_image_width);
    $hy0 = (int) ($hy * $plot_image_height);
    $hx1 = (int) ($h_width * $plot_image_width) + $hx0;
    $hy1 = (int) ($h_height * $plot_image_height) + $hy0;
    $p->SetPlotAreaPixels($hx0, $hy0, $hx1, $hy1);
    $p->DrawGraph();
}
/* Demo main. */
plot_histogram('images/graygradient.png', $param);