Labels

Tuesday, May 20, 2025

Matplotlib add minor ticker

 

import matplotlib.pyplot as plt

from matplotlib.ticker import MultipleLocator, FormatStrFormatter

majorLocator = MultipleLocator(20)
majorFormatter = FormatStrFormatter('%d')
minorLocator = MultipleLocator(5)


t = np.arange(0.0, 100.0, 0.1)
s = np.sin(0.1*np.pi*t)*np.exp(-t*0.01)

fig, ax = plt.subplots()
plt.plot(t, s)

ax.xaxis.set_major_locator(majorLocator)
ax.xaxis.set_major_formatter(majorFormatter)

# for the minor ticks, use no labels; default NullFormatter
ax.xaxis.set_minor_locator(minorLocator)

plt.show()

Reference:
https://matplotlib.org/2.0.2/examples/pylab_examples/major_minor_demo1.html

Thursday, December 19, 2024

restaurant

 BONEFISH GRILL

CARRABBA'S ITALIAN GRILL

CINNABON

MOE'S SOUTHWEST GRILL

Outback Steakhouse

PAPA JOHN’S

SCHLOTZSKY'S

Daily life

 https://www.dmachoice.org/   # do-not-mail service

prepaidcompare.net

daycare:

Montessori School of Madison

O2b Kids 

Primrose

KLA

Rainbow Child Care Center of Huntsville


Happy Times preschool.

Premier 

KidTowne

Kindercare

--------

https://www.colorsfinearts.com/

https://www.artisartstudio.com/

https://hsvgymnastics.com/classes/

https://northalabama.soccershots.com/pd/2097/madison-shelton-park-mini-2yo-thursdays-summe?source=search&returncom=productlist&zip=35758&zipdis=10&st_t=1070&st_ti=1422

https://perfectpraisemusic.com/product/baby-toddler-music-class-in-studio/

gb pockit all city stroller


https://www.uwsublets.com/list-1.php

https://www.facebook.com/groups/284165505043431/

https://www.bestbuy.com/site/searchpage.jsp?browsedCategory=abcat0907007&id=pcat17071&qp=brand_facet%3DBrand%7EDe%27Longhi&st=categoryid%24abcat0907007



Govee temperature sensor


Nasa coloring page: https://science.nasa.gov/toolkit/coloring-books/

weather:
https://acmeaom.com/
Alabama SAF-T-Net    app
https://www.waaytv.com/livestream/
https://whnt.com/whnt-live-stream/
https://www.waff.com/livestream/

waff youtube livestream

https://wehealth.org/




Friday, August 2, 2024

GSL integration

//https://stackoverflow.com/questions/47038457/gsl-integration-within-a-function-c

#include 
#include 
#include 
#include 

namespace details
{
  extern "C" {
  double gsl_function_cpp_wrapper_helper(double z, void *cpp_f)
  {
    const auto p_cpp_f =
        reinterpret_cast *>(cpp_f);
    return (*p_cpp_f)(z);
  }
  }
}

class gsl_function_cpp_wrapper
{
  using Cpp_F = std::function;

 public:
  operator const gsl_function_struct *() const { return &gsl_f_; };

  gsl_function_cpp_wrapper(Cpp_F &&cpp_f) : cpp_f_(std::move(cpp_f))
  {
    gsl_f_.function = details::gsl_function_cpp_wrapper_helper;
    gsl_f_.params = &cpp_f_;
  }

  gsl_function_cpp_wrapper(double(f)(double))
      : gsl_function_cpp_wrapper(Cpp_F(f))
  {
  }

  template 
  gsl_function_cpp_wrapper(double (OBJ::*method)(double) const, const OBJ *obj)
      : gsl_function_cpp_wrapper(
            Cpp_F(std::bind(method, obj, std::placeholders::_1)))
  {
  }
  template 
  gsl_function_cpp_wrapper(double (OBJ::*method)(double), OBJ *obj)
      : gsl_function_cpp_wrapper(
            Cpp_F(std::bind(method, obj, std::placeholders::_1)))
  {
  }

 protected:
  Cpp_F cpp_f_;
  gsl_function_struct gsl_f_;
};

//----------------

class Class_Example
{
 public:
  double f(double x) const { return std::log(alpha_ * x) / std::sqrt(x); }

 protected:
  double alpha_ = 1;
};

double free_function_example(double x)
{
  const double alpha = 1;
  return std::log(alpha * x) / std::sqrt(x);
}

//----------------

int main()
{
  double result, error;
  gsl_integration_workspace *const w = gsl_integration_workspace_alloc(1000);
  assert(w != nullptr);

  //----------------

  Class_Example class_example;

  gsl_function_cpp_wrapper wrapper_1(&Class_Example::f, &class_example);

  gsl_integration_qags(wrapper_1, 0, 1, 0, 1e-7, 1000, w, &result, &error);

  std::printf("result          = % .18f\n", result);
  std::printf("estimated error = % .18f\n", error);

  //----------------

  gsl_function_cpp_wrapper wrapper_2(free_function_example);

  gsl_integration_qags(wrapper_2, 0, 1, 0, 1e-7, 1000, w, &result, &error);

  std::printf("result          = % .18f\n", result);
  std::printf("estimated error = % .18f\n", error);

  //----------------

  gsl_integration_workspace_free(w);

  return EXIT_SUCCESS;
}

GSL interpolation

#include 
#include 
#include 


 double INTERPOLATE1D( double logx,const vector& logx0, const vector& logy0)
 {
     const gsl_interp_type *T = gsl_interp_cspline;//gsl_interp_linear;
     gsl_spline *s = gsl_spline_alloc(T,logx0.size());
     gsl_interp_accel *acc = gsl_interp_accel_alloc();
     gsl_spline_init(s,&logx0[0],&logy0[0],logx0.size());
 
     double logy = gsl_spline_eval(s,logx,acc);
     gsl_spline_free(s);
     gsl_interp_accel_free(acc);
     return pow(10,logy);
 }

Thursday, August 1, 2024

pass parameters in GSL integration

struct my_f_params {int a; int b;}; 
gsl_function F1; 
struct my_f_params alpha = {2,2};               
F1.function = &f1; 
F1.params = & alpha;

struct my_f_params * params = (struct my_f_params *)p;
int n = (params->a);
int m = (params->b);

----------

double params[] = { y, z };
F.params = params;

double y = ((double *)params)[0];
double z =  *((double *)p+1);

Thursday, June 6, 2024

Levi-Civita symbol and cross product

 







Reference:
http://www.homepages.ucl.ac.uk/~ucappgu/seminars/levi-civita.pdf
https://en.wikipedia.org/wiki/Levi-Civita_symbol



Tuesday, December 19, 2023

citation map

https://jokergoo.github.io/2023/02/18/generate-citation-map/

library(V8)

ct = v8()

ct$source("~/citation.json")

citation = ct$get("citation")

results = citation$results[, 1:4] head(results)

tb = data.frame(address = tapply(results$address, results$address, function(x) x[1]), publicationCount = tapply(results$publicationCount, results$address, sum), lat = tapply(results$lat, results$address, mean), lon = tapply(results$lon, results$address, mean))

library("sf") library("rnaturalearth") library("rnaturalearthdata") world = ne_countries(scale = "medium", returnclass = "sf") library(ggplot2) library(ggrepel) library(RColorBrewer) ggplot(data = world) + geom_sf(color = "grey", fill = NA) + geom_point(data = tb[order(tb$publicationCount), ], aes(x = lon, y = lat, color = publicationCount, size = publicationCount)) + scale_colour_gradientn(colours = rev(brewer.pal(9, "Spectral"))) + scale_size(range = c(0.2, 3)) + geom_text_repel(data = tb[order(-tb$publicationCount)[1:20], ], mapping = aes(x = lon, y = lat, label = gsub(", .*$", "", address)), box.padding = 0.5, max.overlaps = Inf, min.segment.length = 0, size = 3)


https://guides.library.harvard.edu/c.php?g=311134&p=4423814

Sunday, December 10, 2023

combine pdf in linux

PDF Arranger is a small python-gtk application, which helps the user to merge or split PDF documents and rotate, crop and rearrange their pages using an interactive and intuitive graphical interface. 


https://github.com/pdfarranger/pdfarranger

Saturday, September 2, 2023

A teacher-created site

 A to Z Teacher Stuff is a teacher-created site designed to help teachers find online resources more quickly and easily. Find lesson plans, thematic units, teacher tips, discussion forums for teachers, downloadable teaching materials, printable worksheets, emergent reader books, themes, and more.


http://atozteacherstuff.com/

Wednesday, August 30, 2023

Average over a sphere surface

 The surface integral of the function $f$ over the surface $S$ is denoted by

\[ \int\int_S f dS \]

$dS$ is the area of an infinitesimal piece of the surface $S$.

Average over the sphere is

\[ <f> = \frac{1}{4\pi} \int_0^{2\pi} d\phi \int_0^{\pi} f \sin(\theta)d\theta ,\]

where $dS=\sin(\theta)d\theta d\phi$. This can be seen as a weight average, the weight is surface area.

\[ <\cos^2(\theta)>=1/3 \]

\[<\sin(\theta)>=2/3.\]