Skip to content

Instantly share code, notes, and snippets.

View jwt625's full-sized avatar
🐢
Alive

Wentao jwt625

🐢
Alive
  • Sunnyvale, CA
  • 01:20 (UTC -07:00)
View GitHub Profile
fn magic_energy<D: Dim>(q: D) -> Energy =
if is_zero(q)
then 0
else if is_dimensionless(q / s) # q is a time: E = h / q
then ℎ / quantity_cast(q, s)
else if is_dimensionless(q * s) # q is a frequency: E = h *q
then ℎ * quantity_cast(q, 1/s)
else if is_dimensionless(q / K) # q is a temperature: E = k_B T
then k_B quantity_cast(q, K)
else if is_dimensionless(q / m) # q is a wavelength: E = ℎ c / λ

You are an expert Python developer who specializes in writing matplotlib code based on a given picture. I found a very nice picture in a STEM paper, but there is no corresponding source code available. I need your help to generate the Python code that can reproduce the picture based on the picture I provide. Note that it is necessary to use proper figsize to set the image size to match the original size. Now, please give me the matplotlib code that reproduces the picture below.

I will give you a long post and ask you to exract tags from it. I will also give you list of example tags from past posts. Here are some example tags:

  • PCSEL
  • Nanotube
  • Lens
  • Optics
  • Flexure
  • RSA
  • Microwave
@jwt625
jwt625 / visual_density_point_grid_20240905.py
Created September 5, 2024 14:06
Visual density of points from a 2D grid. Brute force.
import numpy as np
import matplotlib.pyplot as plt
# Parameters
n_grid = 500
# Create the meshgrid
xs, ys = np.meshgrid(np.arange(1, n_grid+1), np.arange(1, n_grid+1))
# Reshape the grids
@jwt625
jwt625 / tif2png.m
Created January 27, 2024 04:11
convert tif to png in matlab
% Get a list of all TIF files in the current folder
tifFiles = dir('*.tif');
% Loop through each TIF file
for i = 1:length(tifFiles)
% Read the TIF file
tifFileName = tifFiles(i).name;
tifData = imread(tifFileName);
% Convert to PNG
@jwt625
jwt625 / calc_area.lym
Created March 30, 2023 22:51 — forked from g2hollow/calc_area.lym
klayout macro qt area calculator
import pya
class AreaCalculator(pya.QDialog):
"""
This class implements a dialog for calculating area of shapes
in a layout. The calculator adds up shapes in the currently
selected cell and below.
"""
def button_clicked(self, checked):
@jwt625
jwt625 / keybindings.json
Created July 16, 2020 05:33
key bindings for vs code
// Place your key bindings in this file to override the defaults
[
{ "key": "ctrl+`", "command": "workbench.action.focusActiveEditorGroup", "when": "terminalFocus" },
{ "key": "ctrl+`", "command": "workbench.action.terminal.focus", "when": "!terminalFocus" },
]
%YAML 1.2
---
# JEOL jdf & sdf file syntax highlight for sublime
# WTJ, 20180316
# See http://www.sublimetext.com/docs/3/syntax.html
file_extensions:
- jdf
- sdf
scope: source.example-c
@jwt625
jwt625 / rpn.m
Last active January 15, 2018 20:25
simple matlab rpn calculator
function rpn
% simple rpn (Reverse Polish notation) calculator
%
% WTJ
% 20180113
fprintf(['Reverse Polish notation calculator. Type h or help to see available functions.'...
'\n\tWentao Jiang, 20180113\n']);
stack = NaN(10000);
ind = 1;
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jan 4 20:02:31 2018
@author: linqs-wentao
"""
class fiberpull:
def __init__(self, ctrlraddr, d0_fiber=2, d_fiber=1, t_heat=10):